html-validate 10.17.0 → 11.0.0
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/README.md +1 -1
- package/dist/cjs/browser.js +1 -3
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/core-browser.js +2 -2
- package/dist/cjs/core-browser.js.map +1 -1
- package/dist/cjs/core-nodejs.js +2 -6
- package/dist/cjs/core-nodejs.js.map +1 -1
- package/dist/cjs/core.js +50 -65
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/browser.js +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/core-browser.js +2 -2
- package/dist/esm/core-browser.js.map +1 -1
- package/dist/esm/core-nodejs.js +3 -6
- package/dist/esm/core-nodejs.js.map +1 -1
- package/dist/esm/core.js +50 -63
- package/dist/esm/core.js.map +1 -1
- package/dist/esm/html-validate.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/matcher-utils.js +1 -1
- package/dist/esm/matchers.js +1 -1
- package/dist/types/browser.d.ts +40 -156
- package/dist/types/index.d.ts +36 -177
- package/package.json +7 -7
package/dist/cjs/core.js
CHANGED
|
@@ -1155,7 +1155,7 @@ function normalizeAriaNaming(value) {
|
|
|
1155
1155
|
return value;
|
|
1156
1156
|
}
|
|
1157
1157
|
function migrateElement(src) {
|
|
1158
|
-
const implicitRole = normalizeAriaImplicitRole(src.
|
|
1158
|
+
const implicitRole = normalizeAriaImplicitRole(src.aria?.implicitRole);
|
|
1159
1159
|
const result = {
|
|
1160
1160
|
...src,
|
|
1161
1161
|
formAssociated: void 0,
|
|
@@ -1571,12 +1571,21 @@ function sliceLocation(location, begin, end, wrap) {
|
|
|
1571
1571
|
return sliced;
|
|
1572
1572
|
}
|
|
1573
1573
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1574
|
+
const Node = {
|
|
1575
|
+
ELEMENT_NODE: 1,
|
|
1576
|
+
TEXT_NODE: 3,
|
|
1577
|
+
DOCUMENT_NODE: 9,
|
|
1578
|
+
/** element wasn't closed */
|
|
1579
|
+
CLOSED_OPEN: 0,
|
|
1580
|
+
/** element closed with end tag <p>...</p> */
|
|
1581
|
+
CLOSED_END_TAG: 1,
|
|
1582
|
+
/** void element with omitted end tag <input> */
|
|
1583
|
+
CLOSED_VOID_OMITTED: 2,
|
|
1584
|
+
/** self-closed void element <input/> */
|
|
1585
|
+
CLOSED_VOID_SELF_CLOSED: 3,
|
|
1586
|
+
/** element with optional end tag <li>foo<li>bar */
|
|
1587
|
+
CLOSED_IMPLICIT_CLOSED: 4
|
|
1588
|
+
};
|
|
1580
1589
|
|
|
1581
1590
|
const DOCUMENT_NODE_NAME = "#document";
|
|
1582
1591
|
const TEXT_CONTENT = /* @__PURE__ */ Symbol("textContent");
|
|
@@ -1703,7 +1712,7 @@ class DOMNode {
|
|
|
1703
1712
|
}
|
|
1704
1713
|
}
|
|
1705
1714
|
isRootElement() {
|
|
1706
|
-
return this.nodeType ===
|
|
1715
|
+
return this.nodeType === Node.DOCUMENT_NODE;
|
|
1707
1716
|
}
|
|
1708
1717
|
/**
|
|
1709
1718
|
* Tests if two nodes are the same (references the same object).
|
|
@@ -2360,7 +2369,7 @@ function parseSelector(selector) {
|
|
|
2360
2369
|
|
|
2361
2370
|
const TEXT_NODE_NAME = "#text";
|
|
2362
2371
|
function isTextNode(node) {
|
|
2363
|
-
return node?.nodeType ===
|
|
2372
|
+
return node?.nodeType === Node.TEXT_NODE;
|
|
2364
2373
|
}
|
|
2365
2374
|
class TextNode extends DOMNode {
|
|
2366
2375
|
text;
|
|
@@ -2370,7 +2379,7 @@ class TextNode extends DOMNode {
|
|
|
2370
2379
|
* @param location - Source code location of this node.
|
|
2371
2380
|
*/
|
|
2372
2381
|
constructor(text, location) {
|
|
2373
|
-
super(
|
|
2382
|
+
super(Node.TEXT_NODE, TEXT_NODE_NAME, location);
|
|
2374
2383
|
this.text = text;
|
|
2375
2384
|
}
|
|
2376
2385
|
/**
|
|
@@ -2396,16 +2405,8 @@ class TextNode extends DOMNode {
|
|
|
2396
2405
|
const CHILD_ELEMENTS = /* @__PURE__ */ Symbol("childElements");
|
|
2397
2406
|
const ROLE = /* @__PURE__ */ Symbol("role");
|
|
2398
2407
|
const TABINDEX = /* @__PURE__ */ Symbol("tabindex");
|
|
2399
|
-
var NodeClosed = /* @__PURE__ */ ((NodeClosed2) => {
|
|
2400
|
-
NodeClosed2[NodeClosed2["Open"] = 0] = "Open";
|
|
2401
|
-
NodeClosed2[NodeClosed2["EndTag"] = 1] = "EndTag";
|
|
2402
|
-
NodeClosed2[NodeClosed2["VoidOmitted"] = 2] = "VoidOmitted";
|
|
2403
|
-
NodeClosed2[NodeClosed2["VoidSelfClosed"] = 3] = "VoidSelfClosed";
|
|
2404
|
-
NodeClosed2[NodeClosed2["ImplicitClosed"] = 4] = "ImplicitClosed";
|
|
2405
|
-
return NodeClosed2;
|
|
2406
|
-
})(NodeClosed || {});
|
|
2407
2408
|
function isElementNode(node) {
|
|
2408
|
-
return node?.nodeType ===
|
|
2409
|
+
return node?.nodeType === Node.ELEMENT_NODE;
|
|
2409
2410
|
}
|
|
2410
2411
|
function isInvalidTagName(tagName) {
|
|
2411
2412
|
return tagName === "" || tagName === "*";
|
|
@@ -2439,7 +2440,7 @@ class HtmlElement extends DOMNode {
|
|
|
2439
2440
|
nodeType,
|
|
2440
2441
|
tagName,
|
|
2441
2442
|
parent = null,
|
|
2442
|
-
closed =
|
|
2443
|
+
closed = Node.CLOSED_END_TAG,
|
|
2443
2444
|
meta = null,
|
|
2444
2445
|
location
|
|
2445
2446
|
} = details;
|
|
@@ -2480,9 +2481,9 @@ class HtmlElement extends DOMNode {
|
|
|
2480
2481
|
* @param details - Additional element details.
|
|
2481
2482
|
*/
|
|
2482
2483
|
static createElement(tagName, location, details = {}) {
|
|
2483
|
-
const { closed =
|
|
2484
|
+
const { closed = Node.CLOSED_END_TAG, meta = null, parent = null } = details;
|
|
2484
2485
|
return new HtmlElement({
|
|
2485
|
-
nodeType:
|
|
2486
|
+
nodeType: Node.ELEMENT_NODE,
|
|
2486
2487
|
tagName,
|
|
2487
2488
|
parent,
|
|
2488
2489
|
closed,
|
|
@@ -2495,7 +2496,7 @@ class HtmlElement extends DOMNode {
|
|
|
2495
2496
|
*/
|
|
2496
2497
|
static rootNode(location) {
|
|
2497
2498
|
const root = new HtmlElement({
|
|
2498
|
-
nodeType:
|
|
2499
|
+
nodeType: Node.DOCUMENT_NODE,
|
|
2499
2500
|
location
|
|
2500
2501
|
});
|
|
2501
2502
|
root.setAnnotation("#document");
|
|
@@ -2517,7 +2518,7 @@ class HtmlElement extends DOMNode {
|
|
|
2517
2518
|
const closed = isClosed(endToken, meta);
|
|
2518
2519
|
const location = sliceLocation(startToken.location, 1);
|
|
2519
2520
|
return new HtmlElement({
|
|
2520
|
-
nodeType:
|
|
2521
|
+
nodeType: Node.ELEMENT_NODE,
|
|
2521
2522
|
tagName,
|
|
2522
2523
|
parent: open ? parent : null,
|
|
2523
2524
|
closed,
|
|
@@ -2982,12 +2983,12 @@ class HtmlElement extends DOMNode {
|
|
|
2982
2983
|
}
|
|
2983
2984
|
}
|
|
2984
2985
|
function isClosed(endToken, meta) {
|
|
2985
|
-
let closed =
|
|
2986
|
+
let closed = Node.CLOSED_OPEN;
|
|
2986
2987
|
if (meta?.void) {
|
|
2987
|
-
closed =
|
|
2988
|
+
closed = Node.CLOSED_VOID_OMITTED;
|
|
2988
2989
|
}
|
|
2989
2990
|
if (endToken.data[0] === "/>") {
|
|
2990
|
-
closed =
|
|
2991
|
+
closed = Node.CLOSED_VOID_SELF_CLOSED;
|
|
2991
2992
|
}
|
|
2992
2993
|
return closed;
|
|
2993
2994
|
}
|
|
@@ -3074,18 +3075,6 @@ class DOMTree {
|
|
|
3074
3075
|
getElementsByTagName(tagName) {
|
|
3075
3076
|
return this.root.getElementsByTagName(tagName);
|
|
3076
3077
|
}
|
|
3077
|
-
/**
|
|
3078
|
-
* @deprecated use utility function `walk.depthFirst(..)` instead (since 8.21.0).
|
|
3079
|
-
*/
|
|
3080
|
-
visitDepthFirst(callback) {
|
|
3081
|
-
walk.depthFirst(this, callback);
|
|
3082
|
-
}
|
|
3083
|
-
/**
|
|
3084
|
-
* @deprecated use `querySelector(..)` instead (since 8.21.0)
|
|
3085
|
-
*/
|
|
3086
|
-
find(callback) {
|
|
3087
|
-
return this.root.find(callback);
|
|
3088
|
-
}
|
|
3089
3078
|
querySelector(selector) {
|
|
3090
3079
|
return this.root.querySelector(selector);
|
|
3091
3080
|
}
|
|
@@ -5737,14 +5726,12 @@ function parsePattern(pattern) {
|
|
|
5737
5726
|
default: {
|
|
5738
5727
|
if (pattern.startsWith("/") && pattern.endsWith("/")) {
|
|
5739
5728
|
const regexpSource = pattern.slice(1, -1);
|
|
5740
|
-
const
|
|
5741
|
-
return { regexp
|
|
5729
|
+
const regexp = new RegExp(regexpSource);
|
|
5730
|
+
return { regexp, description: regexp.toString() };
|
|
5742
5731
|
}
|
|
5743
|
-
|
|
5744
|
-
`Custom pattern "${pattern}"
|
|
5732
|
+
throw new Error(
|
|
5733
|
+
`Custom pattern "${pattern}" must be wrapped in forward slashes, i.e. "/${pattern}/"`
|
|
5745
5734
|
);
|
|
5746
|
-
const regexp = new RegExp(pattern);
|
|
5747
|
-
return { regexp, description: regexp.toString() };
|
|
5748
5735
|
}
|
|
5749
5736
|
}
|
|
5750
5737
|
}
|
|
@@ -5942,7 +5929,7 @@ class CloseOrder extends Rule {
|
|
|
5942
5929
|
if (current.voidElement) {
|
|
5943
5930
|
return;
|
|
5944
5931
|
}
|
|
5945
|
-
if (active.closed ===
|
|
5932
|
+
if (active.closed === Node.CLOSED_IMPLICIT_CLOSED) {
|
|
5946
5933
|
return;
|
|
5947
5934
|
}
|
|
5948
5935
|
if (active.isRootElement()) {
|
|
@@ -8371,7 +8358,7 @@ Omitted end tags can be ambigious for humans to read and many editors have troub
|
|
|
8371
8358
|
if (!by) {
|
|
8372
8359
|
return;
|
|
8373
8360
|
}
|
|
8374
|
-
if (closed.closed !==
|
|
8361
|
+
if (closed.closed !== Node.CLOSED_IMPLICIT_CLOSED) {
|
|
8375
8362
|
return;
|
|
8376
8363
|
}
|
|
8377
8364
|
const parent = closed.parent;
|
|
@@ -8678,7 +8665,7 @@ class NoRawCharacters extends Rule {
|
|
|
8678
8665
|
return;
|
|
8679
8666
|
}
|
|
8680
8667
|
for (const child of node.childNodes) {
|
|
8681
|
-
if (child.nodeType !==
|
|
8668
|
+
if (child.nodeType !== Node.TEXT_NODE) {
|
|
8682
8669
|
continue;
|
|
8683
8670
|
}
|
|
8684
8671
|
if (matchTemplate.test(child.textContent)) {
|
|
@@ -8909,7 +8896,7 @@ class NoSelfClosing extends Rule {
|
|
|
8909
8896
|
});
|
|
8910
8897
|
}
|
|
8911
8898
|
validateElement(node) {
|
|
8912
|
-
if (node.closed !==
|
|
8899
|
+
if (node.closed !== Node.CLOSED_VOID_SELF_CLOSED) {
|
|
8913
8900
|
return;
|
|
8914
8901
|
}
|
|
8915
8902
|
this.report(node, `<${node.tagName}> must not be self-closed`, null, node.tagName);
|
|
@@ -9542,7 +9529,7 @@ class ScriptElement extends Rule {
|
|
|
9542
9529
|
if (node?.tagName !== "script") {
|
|
9543
9530
|
return;
|
|
9544
9531
|
}
|
|
9545
|
-
if (node.closed !==
|
|
9532
|
+
if (node.closed !== Node.CLOSED_END_TAG) {
|
|
9546
9533
|
this.report(node, `End tag for <${node.tagName}> must not be omitted`);
|
|
9547
9534
|
}
|
|
9548
9535
|
});
|
|
@@ -10085,7 +10072,7 @@ class UnknownCharReference extends Rule {
|
|
|
10085
10072
|
return;
|
|
10086
10073
|
}
|
|
10087
10074
|
for (const child of node.childNodes) {
|
|
10088
|
-
if (child.nodeType !==
|
|
10075
|
+
if (child.nodeType !== Node.TEXT_NODE) {
|
|
10089
10076
|
continue;
|
|
10090
10077
|
}
|
|
10091
10078
|
this.findCharacterReferences(node, child.textContent, child.location, {
|
|
@@ -10822,7 +10809,7 @@ class VoidContent extends Rule {
|
|
|
10822
10809
|
if (!node.voidElement) {
|
|
10823
10810
|
return;
|
|
10824
10811
|
}
|
|
10825
|
-
if (node.closed ===
|
|
10812
|
+
if (node.closed === Node.CLOSED_END_TAG) {
|
|
10826
10813
|
this.report(
|
|
10827
10814
|
null,
|
|
10828
10815
|
`End tag for <${node.tagName}> must be omitted`,
|
|
@@ -10875,7 +10862,7 @@ class VoidStyle extends Rule {
|
|
|
10875
10862
|
if (!node.voidElement) {
|
|
10876
10863
|
return;
|
|
10877
10864
|
}
|
|
10878
|
-
if (node.closed !==
|
|
10865
|
+
if (node.closed !== Node.CLOSED_VOID_SELF_CLOSED) {
|
|
10879
10866
|
return;
|
|
10880
10867
|
}
|
|
10881
10868
|
this.reportError(
|
|
@@ -10887,7 +10874,7 @@ class VoidStyle extends Rule {
|
|
|
10887
10874
|
if (!node.voidElement) {
|
|
10888
10875
|
return;
|
|
10889
10876
|
}
|
|
10890
|
-
if (node.closed !==
|
|
10877
|
+
if (node.closed !== Node.CLOSED_VOID_OMITTED) {
|
|
10891
10878
|
return;
|
|
10892
10879
|
}
|
|
10893
10880
|
this.reportError(
|
|
@@ -12652,7 +12639,7 @@ class EventHandler {
|
|
|
12652
12639
|
}
|
|
12653
12640
|
|
|
12654
12641
|
const name = "html-validate";
|
|
12655
|
-
const version = "
|
|
12642
|
+
const version = "11.0.0";
|
|
12656
12643
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
12657
12644
|
|
|
12658
12645
|
function freeze(src) {
|
|
@@ -13067,7 +13054,7 @@ class Parser {
|
|
|
13067
13054
|
if (matches) {
|
|
13068
13055
|
const intermediaryMeta = this.metaTable.getMetaFor(entry.open);
|
|
13069
13056
|
return HtmlElement.createElement(entry.open, token.location, {
|
|
13070
|
-
closed:
|
|
13057
|
+
closed: Node.CLOSED_OPEN,
|
|
13071
13058
|
meta: intermediaryMeta,
|
|
13072
13059
|
parent
|
|
13073
13060
|
});
|
|
@@ -13150,11 +13137,11 @@ class Parser {
|
|
|
13150
13137
|
this.metaTable,
|
|
13151
13138
|
this.currentNamespace
|
|
13152
13139
|
);
|
|
13153
|
-
const isClosing = !isStartTag || node.closed !==
|
|
13140
|
+
const isClosing = !isStartTag || node.closed !== Node.CLOSED_OPEN;
|
|
13154
13141
|
const isForeign = node.meta?.foreign;
|
|
13155
13142
|
while (this.closeOptional(startToken)) {
|
|
13156
13143
|
const active = this.dom.getActive();
|
|
13157
|
-
active.closed =
|
|
13144
|
+
active.closed = Node.CLOSED_IMPLICIT_CLOSED;
|
|
13158
13145
|
this.closeElement(source, node, active, startToken.location);
|
|
13159
13146
|
this.dom.popActive();
|
|
13160
13147
|
}
|
|
@@ -13195,7 +13182,7 @@ class Parser {
|
|
|
13195
13182
|
if (isClosing) {
|
|
13196
13183
|
const active = this.dom.getActive();
|
|
13197
13184
|
if (!isStartTag) {
|
|
13198
|
-
node.closed =
|
|
13185
|
+
node.closed = Node.CLOSED_END_TAG;
|
|
13199
13186
|
}
|
|
13200
13187
|
this.closeElement(source, node, active, endToken.location);
|
|
13201
13188
|
const mismatched = node.tagName !== active.tagName;
|
|
@@ -13218,7 +13205,7 @@ class Parser {
|
|
|
13218
13205
|
location
|
|
13219
13206
|
};
|
|
13220
13207
|
this.trigger("tag:end", event);
|
|
13221
|
-
if (node && node.tagName !== active.tagName && active.closed !==
|
|
13208
|
+
if (node && node.tagName !== active.tagName && active.closed !== Node.CLOSED_IMPLICIT_CLOSED) {
|
|
13222
13209
|
return;
|
|
13223
13210
|
}
|
|
13224
13211
|
if (!active.isRootElement()) {
|
|
@@ -13575,7 +13562,7 @@ class Parser {
|
|
|
13575
13562
|
let active = this.dom.getActive();
|
|
13576
13563
|
while (!active.isRootElement()) {
|
|
13577
13564
|
if (active.meta?.implicitClosed || active.meta?.optionalEnd) {
|
|
13578
|
-
active.closed =
|
|
13565
|
+
active.closed = Node.CLOSED_IMPLICIT_CLOSED;
|
|
13579
13566
|
this.closeElement(source, documentElement, active, location);
|
|
13580
13567
|
} else {
|
|
13581
13568
|
this.closeElement(source, null, active, location);
|
|
@@ -15359,7 +15346,7 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
|
|
|
15359
15346
|
var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
|
|
15360
15347
|
|
|
15361
15348
|
const engines = {
|
|
15362
|
-
node: "^
|
|
15349
|
+
node: "^22.16.0 || >= 24.0.0"
|
|
15363
15350
|
};
|
|
15364
15351
|
|
|
15365
15352
|
var workerPath = "./jest-worker.js";
|
|
@@ -15378,8 +15365,7 @@ exports.HtmlElement = HtmlElement;
|
|
|
15378
15365
|
exports.MetaCopyableProperty = MetaCopyableProperty;
|
|
15379
15366
|
exports.MetaTable = MetaTable;
|
|
15380
15367
|
exports.NestedError = NestedError;
|
|
15381
|
-
exports.
|
|
15382
|
-
exports.NodeType = NodeType;
|
|
15368
|
+
exports.Node = Node;
|
|
15383
15369
|
exports.Parser = Parser;
|
|
15384
15370
|
exports.PerformanceTracker = PerformanceTracker;
|
|
15385
15371
|
exports.Reporter = Reporter;
|
|
@@ -15392,7 +15378,6 @@ exports.TextClassification = TextClassification;
|
|
|
15392
15378
|
exports.TextContent = TextContent$1;
|
|
15393
15379
|
exports.TextNode = TextNode;
|
|
15394
15380
|
exports.UserError = UserError;
|
|
15395
|
-
exports.Validator = Validator;
|
|
15396
15381
|
exports.WrappedError = WrappedError;
|
|
15397
15382
|
exports.ariaNaming = ariaNaming;
|
|
15398
15383
|
exports.bugs = bugs;
|