@miaskiewicz/turbo-dom 0.1.43 → 0.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miaskiewicz/turbo-dom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "Faster, more spec-correct DOM for test runners — native html5ever (Rust/WASM) parser + lazy copy-on-write DOM. A drop-in-style alternative to jsdom/happy-dom for vitest & jest.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"prepublishOnly": "napi build --platform --release",
|
|
71
71
|
"test:vitest": "vitest run -c test-vitest/vitest.config.mjs",
|
|
72
72
|
"test:jest": "jest -c test-jest/jest.config.cjs",
|
|
73
|
-
"bench:query": "node bench/query.mjs"
|
|
73
|
+
"bench:query": "node bench/query.mjs",
|
|
74
|
+
"bench:scorecard": "node bench/scorecard.mjs"
|
|
74
75
|
},
|
|
75
76
|
"keywords": [
|
|
76
77
|
"dom",
|
package/src/runtime/dom.mjs
CHANGED
|
@@ -98,9 +98,10 @@ export class Node extends EventTarget {
|
|
|
98
98
|
if (this.__idx >= 0 && doc && doc.__buf) {
|
|
99
99
|
const buf = doc.__buf;
|
|
100
100
|
for (let c = buf.firstChild(this.__idx); c !== -1; c = buf.nextSib(c)) {
|
|
101
|
+
const nt = buf.nodeType(c); // read once, pass to __nodeAt (was re-read in its switch)
|
|
101
102
|
// template content fragment is not a child — it's `.content`
|
|
102
|
-
if (
|
|
103
|
-
const child = doc.__nodeAt(c);
|
|
103
|
+
if (nt === DOCUMENT_FRAGMENT_NODE && buf.tagName(c) === 'content') continue;
|
|
104
|
+
const child = doc.__nodeAt(c, nt);
|
|
104
105
|
child.parentNode = this;
|
|
105
106
|
kids.push(child);
|
|
106
107
|
}
|
|
@@ -1402,13 +1403,16 @@ export class Document extends Node {
|
|
|
1402
1403
|
}
|
|
1403
1404
|
|
|
1404
1405
|
// nodeAt: one handle per buffer index, memoized → preserves === identity.
|
|
1405
|
-
|
|
1406
|
+
// `nt` (nodeType) may be passed by callers that already read it (__children),
|
|
1407
|
+
// avoiding a second buffer read; other callers leave it undefined.
|
|
1408
|
+
__nodeAt(idx, nt) {
|
|
1406
1409
|
if (idx < 0) return null;
|
|
1407
1410
|
const cached = this.__cache[idx];
|
|
1408
1411
|
if (cached !== undefined) return cached;
|
|
1409
1412
|
const buf = this.__buf;
|
|
1410
1413
|
let node;
|
|
1411
|
-
|
|
1414
|
+
if (nt === undefined) nt = buf.nodeType(idx);
|
|
1415
|
+
switch (nt) {
|
|
1412
1416
|
case ELEMENT_NODE: {
|
|
1413
1417
|
const tag = buf.tagName(idx); // read once (was read twice — ctor + template check)
|
|
1414
1418
|
node = new Element(this, tag, buf.ns(idx));
|
|
Binary file
|