diff --git a/.changeset/serious-ladybugs-bow.md b/.changeset/serious-ladybugs-bow.md new file mode 100644 index 00000000..328649b2 --- /dev/null +++ b/.changeset/serious-ladybugs-bow.md @@ -0,0 +1,5 @@ +--- +'@remote-dom/polyfill': patch +--- + +Fix removeChild so it clears parent/sibling references diff --git a/.changeset/warm-oranges-rest.md b/.changeset/warm-oranges-rest.md new file mode 100644 index 00000000..1f106ead --- /dev/null +++ b/.changeset/warm-oranges-rest.md @@ -0,0 +1,5 @@ +--- +'@remote-dom/polyfill': patch +--- + +Add node.parentElement diff --git a/packages/polyfill/source/Node.ts b/packages/polyfill/source/Node.ts index 22026d33..af1a5705 100644 --- a/packages/polyfill/source/Node.ts +++ b/packages/polyfill/source/Node.ts @@ -62,6 +62,14 @@ export class Node extends EventTarget { set parentNode(_readonly) {} + get parentElement(): ParentNode | null { + const parent = this[PARENT]; + if (!parent || parent.nodeType !== 1) return null; + return parent; + } + + set parentElement(_readonly) {} + get previousSibling() { return this[PREV]; } diff --git a/packages/polyfill/source/ParentNode.ts b/packages/polyfill/source/ParentNode.ts index b3aed87d..b40d0c34 100644 --- a/packages/polyfill/source/ParentNode.ts +++ b/packages/polyfill/source/ParentNode.ts @@ -68,6 +68,10 @@ export class ParentNode extends ChildNode { children.splice(children.indexOf(child), 1); } + child[PARENT] = null; + child[NEXT] = null; + child[PREV] = null; + if (this[IS_CONNECTED]) { for (const node of selfAndDescendants(child)) { node[IS_CONNECTED] = false;