| 117 | } |
| 118 | |
| 119 | removeChild(index: number): SplootNode { |
| 120 | if (index >= this.children.length) { |
| 121 | console.warn("Attempting to delete child that doesn't exist!!", index, this.childParentRef.childSetId) |
| 122 | } |
| 123 | const child = this.children.splice(index, 1)[0] |
| 124 | child.beforeRemoval() |
| 125 | child.parent = null |
| 126 | child.recursivelyClearValidation() |
| 127 | if (this.enableMutations) { |
| 128 | child.recursivelySetMutations(false) |
| 129 | const parent = this.getParentRef().node |
| 130 | parent.validateSelf() |
| 131 | const mutation = new ChildSetMutation() |
| 132 | mutation.type = ChildSetMutationType.DELETE |
| 133 | mutation.childSet = this |
| 134 | mutation.nodes = [] |
| 135 | mutation.index = index |
| 136 | this.fireMutation(mutation) |
| 137 | } |
| 138 | child.recursivelyClearObservers() |
| 139 | return child |
| 140 | } |
| 141 | |
| 142 | recursivelyClearObservers() { |
| 143 | this.mutationObservers = [] |