(child, index)
| 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; |
no test coverage detected