@miaskiewicz/turbo-dom 0.1.44 → 0.1.45
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.45",
|
|
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",
|
package/src/runtime/window.mjs
CHANGED
|
@@ -85,6 +85,7 @@ const hostClearTimeout = globalThis.clearTimeout;
|
|
|
85
85
|
// self-replaces onto the per-env base, so each env gets its own instance; only
|
|
86
86
|
// the factory objects/closures are shared, saving ~28 allocations per test file.
|
|
87
87
|
const SHARED_LAZY = {
|
|
88
|
+
customElements: () => makeCustomElements(), // fresh registry per env, built on first access
|
|
88
89
|
localStorage: () => new Storage(),
|
|
89
90
|
sessionStorage: () => new Storage(),
|
|
90
91
|
matchMedia: () => makeMatchMedia(),
|
|
@@ -133,7 +134,8 @@ export function createWindow(document, { url = 'http://localhost/' } = {}) {
|
|
|
133
134
|
name: '',
|
|
134
135
|
closed: false,
|
|
135
136
|
origin: new URL(url).origin,
|
|
136
|
-
customElements
|
|
137
|
+
// customElements is lazy (SHARED_LAZY) — env-independent + rarely used; building
|
|
138
|
+
// its two Maps eagerly per createWindow was wasted for the typical test.
|
|
137
139
|
Image: function Image(w, h) { const img = document.createElement('img'); if (w != null) img.setAttribute('width', w); if (h != null) img.setAttribute('height', h); return img; },
|
|
138
140
|
Audio: function Audio(src) { const a = document.createElement('audio'); if (src) a.setAttribute('src', src); return a; },
|
|
139
141
|
getSelection: () => document.getSelection(),
|
|
Binary file
|