MCPcopy Create free account
hub / github.com/ElemeFE/element-react / insertChild

Method insertChild

src/tree/model/node.js:147–167  ·  view source on GitHub ↗
(child, index)

Source from the content-addressed store, hash-verified

145 }
146
147 insertChild(child, index) {
148 if (!child) throw new Error('insertChild error: child is required.');
149
150 if (!(child instanceof Node)) {
151 Object.assign(child, {
152 parent: this,
153 store: this.store
154 });
155 child = new Node(child);
156 }
157
158 child.level = this.level + 1;
159
160 if (typeof index === 'undefined' || index < 0) {
161 this.childNodes.push(child);
162 } else {
163 this.childNodes.splice(index, 0, child);
164 }
165
166 this.updateLeafState();
167 }
168
169 insertBefore(child, ref) {
170 let index;

Callers 6

setDataMethod · 0.95
insertBeforeMethod · 0.95
insertAfterMethod · 0.95
doCreateChildrenMethod · 0.95
updateChildrenMethod · 0.95
appendMethod · 0.80

Calls 1

updateLeafStateMethod · 0.95

Tested by

no test coverage detected