8000 fix: fix crash when aria attribute references id with comma · html-validate/html-validate@fb91b7c · GitHub
[go: up one dir, main page]

Skip to content

Commit fb91b7c

Browse files
committed
fix: fix crash when aria attribute references id with comma
fixes #299
1 parent 5bd7106 commit fb91b7c

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

src/__snapshots__/regression.spec.ts.snap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ exports[`regression tests test-files/issues/issue-138-srcset-line-wrapping.html
66

77
exports[`regression tests test-files/issues/issue-154-case-insensitive-attr.html 1`] = `[]`;
88

9-
exports[`regression tests test-files/issues/issue-299-comma-id.html 1`] = `
9+
exports[`regression tests test-files/issues/issue-299/issue-299-comma-id.html 1`] = `
1010
[
1111
{
1212
"errorCount": 1,
13-
"filePath": "test-files/issues/issue-299-comma-id.html",
13+
"filePath": "test-files/issues/issue-299/issue-299-comma-id.html",
1414
"messages": [
1515
{
1616
"column": 10,
@@ -29,6 +29,7 @@ exports[`regression tests test-files/issues/issue-299-comma-id.html 1`] = `
2929
},
3030
],
3131
"source": "<div id="start,-end"></div>
32+
<div aria-controls="start,-end" aria-labelledby="start,-end"></div>
3233
",
3334
"warningCount": 0,
3435
},

src/rules/no-missing-references.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { type Attribute, type DOMTree, type HtmlElement, DOMTokenList, DynamicValue } from "../dom";
1+
import {
2+
type Attribute,
3+
type DOMTree,
4+
type HtmlElement,
5+
DOMTokenList,
6+
DynamicValue,
7+
generateIdSelector,
8+
} from "../dom";
29
import { type DOMReadyEvent } from "../event";
310
import { type RuleDocumentation, Rule, ruleDocumentationUrl } from "../rule";
411

@@ -24,7 +31,7 @@ const ARIA: AriaAttribute[] = [
2431
];
2532

2633
function idMissing(document: DOMTree, id: string): boolean {
27-
const nodes = document.querySelectorAll(`[id="${id}"]`);
34+
const nodes = document.querySelectorAll(generateIdSelector(id));
2835
return nodes.length === 0;
2936
}
3037

test-files/issues/issue-299-comma-id.html

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["html-validate:recommended", "html-validate:document"]
3+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div id="start,-end"></div>
2+
<div aria-controls="start,-end" aria-labelledby="start,-end"></div>

0 commit comments

Comments
 (0)
0