From ada3e2b9444f77778d19837cb136f52057ebdcf8 Mon Sep 17 00:00:00 2001 From: zirkelc Date: Tue, 22 Sep 2026 20:25:08 +0200 Subject: [PATCH] perf(parent-node): allocate the end marker without symbol keys in the literal --- cjs/mixin/parent-node.js | 11 +++++++---- esm/mixin/parent-node.js | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cjs/mixin/parent-node.js b/cjs/mixin/parent-node.js index 47590b42..1aaa3e0d 100644 --- a/cjs/mixin/parent-node.js +++ b/cjs/mixin/parent-node.js @@ -52,14 +52,17 @@ class ParentNode extends Node { super(ownerDocument, localName, nodeType); this[PRIVATE] = null; /** @type {NodeStruct} */ - this[NEXT] = this[END] = { - [NEXT]: null, - [PREV]: this, - [START]: this, + // the links are added after the literal: a literal with symbol keys allocates through a + // slower path, and this marker is created for every node + const end = { nodeType: NODE_END, ownerDocument: this.ownerDocument, parentNode: null }; + end[NEXT] = null; + end[PREV] = this; + end[START] = this; + this[NEXT] = this[END] = end; } get childNodes() { diff --git a/esm/mixin/parent-node.js b/esm/mixin/parent-node.js index b54c4a0e..fcaa0a8e 100644 --- a/esm/mixin/parent-node.js +++ b/esm/mixin/parent-node.js @@ -51,14 +51,17 @@ export class ParentNode extends Node { super(ownerDocument, localName, nodeType); this[PRIVATE] = null; /** @type {NodeStruct} */ - this[NEXT] = this[END] = { - [NEXT]: null, - [PREV]: this, - [START]: this, + // the links are added after the literal: a literal with symbol keys allocates through a + // slower path, and this marker is created for every node + const end = { nodeType: NODE_END, ownerDocument: this.ownerDocument, parentNode: null }; + end[NEXT] = null; + end[PREV] = this; + end[START] = this; + this[NEXT] = this[END] = end; } get childNodes() {