(...nodes)
| 350 | } |
| 351 | |
| 352 | replaceWith(...nodes) { |
| 353 | if (this.parent) { |
| 354 | let bookmark = this |
| 355 | let foundSelf = false |
| 356 | for (let node of nodes) { |
| 357 | if (node === this) { |
| 358 | foundSelf = true |
| 359 | } else if (foundSelf) { |
| 360 | this.parent.insertAfter(bookmark, node) |
| 361 | bookmark = node |
| 362 | } else { |
| 363 | this.parent.insertBefore(bookmark, node) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | if (!foundSelf) { |
| 368 | this.remove() |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | return this |
| 373 | } |
| 374 | |
| 375 | root() { |
| 376 | let result = this |