MCPcopy
hub / github.com/adobe/react-spectrum / appendChild

Method appendChild

packages/react-aria/src/collections/Document.ts:126–152  ·  view source on GitHub ↗
(child: ElementNode<T>)

Source from the content-addressed store, hash-verified

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) {

Callers 15

insertBeforeMethod · 0.95
AppFunction · 0.80
usePress.test.jsFile · 0.80
domHelpers.test.jsFile · 0.80
getNonce.test.jsFile · 0.80
appendElementFunction · 0.80

Calls 3

markDirtyMethod · 0.80
queueUpdateMethod · 0.80
removeChildMethod · 0.45

Tested by 6

AppFunction · 0.64
appendElementFunction · 0.64
checkPositionCommonFunction · 0.64
mutateFunction · 0.64
createNestedShadowRootFunction · 0.64