Ejemplo n.º 1
0
        public void AdoptAttributes(HtmlElement recipient, ArraySegment <HtmlAttribute> attributes)
        {
            var recipientAttributes = recipient.Attributes;

            HashSet <string> recipientAttrsMap = null;

            if (recipientAttributes.Count > 0)
            {
                recipientAttrsMap = new HashSet <string>();

                for (var i = 0; i < recipientAttributes.Count; i++)
                {
                    recipientAttrsMap.Add(recipientAttributes[i].Name);
                }
            }

            for (var i = attributes.Offset; i < attributes.Count; i++)
            {
                var attr = attributes.Array[i];
                if (recipientAttrsMap == null || !recipientAttrsMap.Contains(attr.Name))
                {
                    recipient.AttributesPush(attr);
                }
            }
        }
Ejemplo n.º 2
0
        public void AdoptAttributes(HtmlElement recipient, ArraySegment <HtmlAttribute> attributes)
        {
            var recipientAttrsMap = new HashSet <string>();

            foreach (var attr in recipient.Attributes)
            {
                recipientAttrsMap.Add(attr.Name);
            }

            foreach (var attr in attributes)
            {
                if (!recipientAttrsMap.Contains(attr.Name))
                {
                    recipient.AttributesPush(attr);
                }
            }
        }