@miaskiewicz/turbo-dom 0.1.15 → 0.1.16
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.16",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
package/src/runtime/dom.mjs
CHANGED
|
@@ -344,13 +344,20 @@ export class Element extends Node {
|
|
|
344
344
|
!(this.localName === 'input' && this.getAttribute('type') === 'hidden');
|
|
345
345
|
if (!labelable) return undefined;
|
|
346
346
|
const out = [];
|
|
347
|
+
// explicit association: <label for="thisId">
|
|
347
348
|
if (this.id) {
|
|
348
349
|
for (const l of this.ownerDocument.getElementsByTagName('label')) {
|
|
349
350
|
if (l.getAttribute('for') === this.id) out.push(l);
|
|
350
351
|
}
|
|
351
352
|
}
|
|
353
|
+
// implicit association: an ancestor <label> — but ONLY if THIS element is
|
|
354
|
+
// that label's labeled control (the first labelable descendant). A second
|
|
355
|
+
// control nested in the same label is NOT labeled by it.
|
|
352
356
|
let p = this.parentNode;
|
|
353
|
-
while (p) {
|
|
357
|
+
while (p) {
|
|
358
|
+
if (p.localName === 'label') { if (p.control === this && !out.includes(p)) out.push(p); break; }
|
|
359
|
+
p = p.parentNode;
|
|
360
|
+
}
|
|
354
361
|
return out;
|
|
355
362
|
}
|
|
356
363
|
get className() { return this.getAttribute('class') || ''; }
|
|
Binary file
|