MCPcopy Create free account
hub / github.com/adobe/react-spectrum / appendChild

Method appendChild

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

Source from the content-addressed store, hash-verified

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

Callers 15

insertBeforeMethod · 0.95
AppFunction · 0.80
usePress.test.jsFile · 0.80
domHelpers.test.jsFile · 0.80
keyboard.test.tsFile · 0.80

Calls 3

markDirtyMethod · 0.80
queueUpdateMethod · 0.80
removeChildMethod · 0.45

Tested by 10

AppFunction · 0.64
appendElementFunction · 0.64
checkPositionCommonFunction · 0.64
mutateFunction · 0.64
createNestedShadowRootFunction · 0.64
renderInShadowRootFunction · 0.64
makeScrollableContainerFunction · 0.64
ShadowPortalFunction · 0.64
mountInShadowFunction · 0.64