(
/** @type {HtmlElement} */ commonAncestor
)
| 5496 | }; |
| 5497 | |
| 5498 | const placeForCommonAncestor = ( |
| 5499 | /** @type {HtmlElement} */ commonAncestor |
| 5500 | ) => { |
| 5501 | if ( |
| 5502 | TABLE_CONTEXT.has(commonAncestor.tagName) && |
| 5503 | commonAncestor.namespace === NS_HTML |
| 5504 | ) { |
| 5505 | // foster |
| 5506 | // reuse appropriatePlace logic but rooted differently: emulate |
| 5507 | let lastTemplate = -1; |
| 5508 | let lastTable = -1; |
| 5509 | for (let i = open.length - 1; i >= 0; i--) { |
| 5510 | if ( |
| 5511 | open[i].tagName === "template" && |
| 5512 | open[i].namespace === NS_HTML && |
| 5513 | lastTemplate === -1 |
| 5514 | ) { |
| 5515 | lastTemplate = i; |
| 5516 | } |
| 5517 | if ( |
| 5518 | open[i].tagName === "table" && |
| 5519 | open[i].namespace === NS_HTML && |
| 5520 | lastTable === -1 |
| 5521 | ) { |
| 5522 | lastTable = i; |
| 5523 | } |
| 5524 | } |
| 5525 | if ( |
| 5526 | lastTemplate !== -1 && |
| 5527 | (lastTable === -1 || lastTemplate > lastTable) |
| 5528 | ) { |
| 5529 | return { parent: open[lastTemplate], beforeNode: null }; |
| 5530 | } |
| 5531 | if (lastTable === -1) return { parent: open[0], beforeNode: null }; |
| 5532 | const table = open[lastTable]; |
| 5533 | const tp = findParent(table); |
| 5534 | if (tp) return { parent: tp, beforeNode: table }; |
| 5535 | return { parent: open[lastTable - 1], beforeNode: null }; |
| 5536 | } |
| 5537 | return { parent: commonAncestor, beforeNode: null }; |
| 5538 | }; |
| 5539 | |
| 5540 | const detach = (/** @type {HtmlNode} */ node) => { |
| 5541 | const p = findParent(node); |
no test coverage detected