Ejemplo n.º 1
0
        public override void Insert(int index, DomNode item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            int currentIndex = IndexOf(item);

            if (currentIndex == index)
            {
                return;
            }

            if (currentIndex >= 0)
            {
                _items.Remove(item);
                index = Math.Max(0, index - 1);
            }
            if (item.IsDocumentFragment)
            {
                InsertRange(index, item.ChildNodes);
            }
            else
            {
                Entering(item, null);
                _items.Insert(index, item);
                item.NotifyParentChanged();
                _owner.ChildNodeChanged(DomMutation.Add, item, GetPreviousSibling(item), GetNextSibling(item));
            }
        }