| 124 | } |
| 125 | |
| 126 | appendChild(child: ElementNode<T>): void { |
| 127 | if (child.parentNode) { |
| 128 | child.parentNode.removeChild(child); |
| 129 | } |
| 130 | |
| 131 | if (this.firstChild == null) { |
| 132 | this.firstChild = child; |
| 133 | } |
| 134 | |
| 135 | if (this.lastChild) { |
| 136 | this.lastChild.nextSibling = child; |
| 137 | child.index = this.lastChild.index + 1; |
| 138 | child.previousSibling = this.lastChild; |
| 139 | } else { |
| 140 | child.previousSibling = null; |
| 141 | child.index = 0; |
| 142 | } |
| 143 | |
| 144 | child.parentNode = this; |
| 145 | child.nextSibling = null; |
| 146 | this.lastChild = child; |
| 147 | |
| 148 | this.ownerDocument.markDirty(this); |
| 149 | if (this.isConnected) { |
| 150 | this.ownerDocument.queueUpdate(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | insertBefore(newNode: ElementNode<T>, referenceNode: ElementNode<T>): void { |
| 155 | if (referenceNode == null) { |