html-validate 8.16.0 → 8.17.1
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/dist/cjs/core.js +170 -107
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/tsdoc-metadata.json +1 -1
- package/dist/es/core.js +170 -107
- package/dist/es/core.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +8 -8
package/dist/cjs/core.js
CHANGED
|
@@ -1400,10 +1400,14 @@ function expandRegexValue(value) {
|
|
|
1400
1400
|
if (value instanceof RegExp) {
|
|
1401
1401
|
return value;
|
|
1402
1402
|
}
|
|
1403
|
-
const match = value.match(
|
|
1403
|
+
const match = value.match(/^\/(.*(?=\/))\/(i?)$/);
|
|
1404
1404
|
if (match) {
|
|
1405
1405
|
const [, expr, flags] = match;
|
|
1406
|
-
|
|
1406
|
+
if (expr.startsWith("^") || expr.endsWith("$")) {
|
|
1407
|
+
return new RegExp(expr, flags);
|
|
1408
|
+
} else {
|
|
1409
|
+
return new RegExp(`^${expr}$`, flags);
|
|
1410
|
+
}
|
|
1407
1411
|
} else {
|
|
1408
1412
|
return value;
|
|
1409
1413
|
}
|
|
@@ -3441,13 +3445,13 @@ function inAccessibilityTree(node) {
|
|
|
3441
3445
|
return true;
|
|
3442
3446
|
}
|
|
3443
3447
|
function isAriaHiddenImpl(node) {
|
|
3444
|
-
const
|
|
3448
|
+
const getAriaHiddenAttr = (node2) => {
|
|
3445
3449
|
const ariaHidden = node2.getAttribute("aria-hidden");
|
|
3446
3450
|
return Boolean(ariaHidden && ariaHidden.value === "true");
|
|
3447
3451
|
};
|
|
3448
3452
|
return {
|
|
3449
3453
|
byParent: node.parent ? isAriaHidden(node.parent) : false,
|
|
3450
|
-
bySelf:
|
|
3454
|
+
bySelf: getAriaHiddenAttr(node)
|
|
3451
3455
|
};
|
|
3452
3456
|
}
|
|
3453
3457
|
function isAriaHidden(node, details) {
|
|
@@ -3459,13 +3463,13 @@ function isAriaHidden(node, details) {
|
|
|
3459
3463
|
return details ? result : result.byParent || result.bySelf;
|
|
3460
3464
|
}
|
|
3461
3465
|
function isHTMLHiddenImpl(node) {
|
|
3462
|
-
const
|
|
3466
|
+
const getHiddenAttr = (node2) => {
|
|
3463
3467
|
const hidden = node2.getAttribute("hidden");
|
|
3464
3468
|
return hidden !== null && hidden.isStatic;
|
|
3465
3469
|
};
|
|
3466
3470
|
return {
|
|
3467
3471
|
byParent: node.parent ? isHTMLHidden(node.parent) : false,
|
|
3468
|
-
bySelf:
|
|
3472
|
+
bySelf: getHiddenAttr(node)
|
|
3469
3473
|
};
|
|
3470
3474
|
}
|
|
3471
3475
|
function isHTMLHidden(node, details) {
|
|
@@ -3477,13 +3481,13 @@ function isHTMLHidden(node, details) {
|
|
|
3477
3481
|
return details ? result : result.byParent || result.bySelf;
|
|
3478
3482
|
}
|
|
3479
3483
|
function isInertImpl(node) {
|
|
3480
|
-
const
|
|
3484
|
+
const getInertAttr = (node2) => {
|
|
3481
3485
|
const inert = node2.getAttribute("inert");
|
|
3482
3486
|
return inert !== null && inert.isStatic;
|
|
3483
3487
|
};
|
|
3484
3488
|
return {
|
|
3485
|
-
byParent: node.parent ?
|
|
3486
|
-
bySelf:
|
|
3489
|
+
byParent: node.parent ? isInert(node.parent) : false,
|
|
3490
|
+
bySelf: getInertAttr(node)
|
|
3487
3491
|
};
|
|
3488
3492
|
}
|
|
3489
3493
|
function isInert(node, details) {
|
|
@@ -3495,13 +3499,13 @@ function isInert(node, details) {
|
|
|
3495
3499
|
return details ? result : result.byParent || result.bySelf;
|
|
3496
3500
|
}
|
|
3497
3501
|
function isStyleHiddenImpl(node) {
|
|
3498
|
-
const
|
|
3502
|
+
const getStyleAttr = (node2) => {
|
|
3499
3503
|
const style = node2.getAttribute("style");
|
|
3500
3504
|
const { display, visibility } = parseCssDeclaration(style == null ? void 0 : style.value);
|
|
3501
3505
|
return display === "none" || visibility === "hidden";
|
|
3502
3506
|
};
|
|
3503
3507
|
const byParent = node.parent ? isStyleHidden(node.parent) : false;
|
|
3504
|
-
const bySelf =
|
|
3508
|
+
const bySelf = getStyleAttr(node);
|
|
3505
3509
|
return byParent || bySelf;
|
|
3506
3510
|
}
|
|
3507
3511
|
function isStyleHidden(node) {
|
|
@@ -3919,7 +3923,7 @@ class Rule {
|
|
|
3919
3923
|
}
|
|
3920
3924
|
}
|
|
3921
3925
|
|
|
3922
|
-
const defaults$
|
|
3926
|
+
const defaults$x = {
|
|
3923
3927
|
allowExternal: true,
|
|
3924
3928
|
allowRelative: true,
|
|
3925
3929
|
allowAbsolute: true,
|
|
@@ -3960,7 +3964,7 @@ function matchList(value, list) {
|
|
|
3960
3964
|
}
|
|
3961
3965
|
class AllowedLinks extends Rule {
|
|
3962
3966
|
constructor(options) {
|
|
3963
|
-
super({ ...defaults$
|
|
3967
|
+
super({ ...defaults$x, ...options });
|
|
3964
3968
|
this.allowExternal = parseAllow(this.options.allowExternal);
|
|
3965
3969
|
this.allowRelative = parseAllow(this.options.allowRelative);
|
|
3966
3970
|
this.allowAbsolute = parseAllow(this.options.allowAbsolute);
|
|
@@ -4124,7 +4128,7 @@ class AllowedLinks extends Rule {
|
|
|
4124
4128
|
}
|
|
4125
4129
|
}
|
|
4126
4130
|
|
|
4127
|
-
const defaults$
|
|
4131
|
+
const defaults$w = {
|
|
4128
4132
|
accessible: true
|
|
4129
4133
|
};
|
|
4130
4134
|
function findByTarget(target, siblings) {
|
|
@@ -4154,7 +4158,7 @@ function getDescription$1(context) {
|
|
|
4154
4158
|
}
|
|
4155
4159
|
class AreaAlt extends Rule {
|
|
4156
4160
|
constructor(options) {
|
|
4157
|
-
super({ ...defaults$
|
|
4161
|
+
super({ ...defaults$w, ...options });
|
|
4158
4162
|
}
|
|
4159
4163
|
static schema() {
|
|
4160
4164
|
return {
|
|
@@ -4233,7 +4237,7 @@ class AriaHiddenBody extends Rule {
|
|
|
4233
4237
|
}
|
|
4234
4238
|
}
|
|
4235
4239
|
|
|
4236
|
-
const defaults$
|
|
4240
|
+
const defaults$v = {
|
|
4237
4241
|
allowAnyNamable: false
|
|
4238
4242
|
};
|
|
4239
4243
|
const whitelisted = [
|
|
@@ -4275,7 +4279,7 @@ function isValidUsage(target, meta) {
|
|
|
4275
4279
|
}
|
|
4276
4280
|
class AriaLabelMisuse extends Rule {
|
|
4277
4281
|
constructor(options) {
|
|
4278
|
-
super({ ...defaults$
|
|
4282
|
+
super({ ...defaults$v, ...options });
|
|
4279
4283
|
}
|
|
4280
4284
|
documentation() {
|
|
4281
4285
|
const valid = [
|
|
@@ -4385,13 +4389,13 @@ class CaseStyle {
|
|
|
4385
4389
|
}
|
|
4386
4390
|
}
|
|
4387
4391
|
|
|
4388
|
-
const defaults$
|
|
4392
|
+
const defaults$u = {
|
|
4389
4393
|
style: "lowercase",
|
|
4390
4394
|
ignoreForeign: true
|
|
4391
4395
|
};
|
|
4392
4396
|
class AttrCase extends Rule {
|
|
4393
4397
|
constructor(options) {
|
|
4394
|
-
super({ ...defaults$
|
|
4398
|
+
super({ ...defaults$u, ...options });
|
|
4395
4399
|
this.style = new CaseStyle(this.options.style, "attr-case");
|
|
4396
4400
|
}
|
|
4397
4401
|
static schema() {
|
|
@@ -4747,7 +4751,7 @@ class AttrDelimiter extends Rule {
|
|
|
4747
4751
|
}
|
|
4748
4752
|
|
|
4749
4753
|
const DEFAULT_PATTERN = "[a-z0-9-:]+";
|
|
4750
|
-
const defaults$
|
|
4754
|
+
const defaults$t = {
|
|
4751
4755
|
pattern: DEFAULT_PATTERN,
|
|
4752
4756
|
ignoreForeign: true
|
|
4753
4757
|
};
|
|
@@ -4779,7 +4783,7 @@ function generateDescription(name, pattern) {
|
|
|
4779
4783
|
}
|
|
4780
4784
|
class AttrPattern extends Rule {
|
|
4781
4785
|
constructor(options) {
|
|
4782
|
-
super({ ...defaults$
|
|
4786
|
+
super({ ...defaults$t, ...options });
|
|
4783
4787
|
this.pattern = generateRegexp(this.options.pattern);
|
|
4784
4788
|
}
|
|
4785
4789
|
static schema() {
|
|
@@ -4826,7 +4830,7 @@ class AttrPattern extends Rule {
|
|
|
4826
4830
|
}
|
|
4827
4831
|
}
|
|
4828
4832
|
|
|
4829
|
-
const defaults$
|
|
4833
|
+
const defaults$s = {
|
|
4830
4834
|
style: "auto",
|
|
4831
4835
|
unquoted: false
|
|
4832
4836
|
};
|
|
@@ -4865,7 +4869,7 @@ function describeStyle(style, unquoted) {
|
|
|
4865
4869
|
}
|
|
4866
4870
|
class AttrQuotes extends Rule {
|
|
4867
4871
|
constructor(options) {
|
|
4868
|
-
super({ ...defaults$
|
|
4872
|
+
super({ ...defaults$s, ...options });
|
|
4869
4873
|
this.style = parseStyle$3(this.options.style);
|
|
4870
4874
|
}
|
|
4871
4875
|
static schema() {
|
|
@@ -5049,12 +5053,12 @@ class AttributeAllowedValues extends Rule {
|
|
|
5049
5053
|
}
|
|
5050
5054
|
}
|
|
5051
5055
|
|
|
5052
|
-
const defaults$
|
|
5056
|
+
const defaults$r = {
|
|
5053
5057
|
style: "omit"
|
|
5054
5058
|
};
|
|
5055
5059
|
class AttributeBooleanStyle extends Rule {
|
|
5056
5060
|
constructor(options) {
|
|
5057
|
-
super({ ...defaults$
|
|
5061
|
+
super({ ...defaults$r, ...options });
|
|
5058
5062
|
this.hasInvalidStyle = parseStyle$2(this.options.style);
|
|
5059
5063
|
}
|
|
5060
5064
|
static schema() {
|
|
@@ -5121,12 +5125,12 @@ function reportMessage$1(attr, style) {
|
|
|
5121
5125
|
return "";
|
|
5122
5126
|
}
|
|
5123
5127
|
|
|
5124
|
-
const defaults$
|
|
5128
|
+
const defaults$q = {
|
|
5125
5129
|
style: "omit"
|
|
5126
5130
|
};
|
|
5127
5131
|
class AttributeEmptyStyle extends Rule {
|
|
5128
5132
|
constructor(options) {
|
|
5129
|
-
super({ ...defaults$
|
|
5133
|
+
super({ ...defaults$q, ...options });
|
|
5130
5134
|
this.hasInvalidStyle = parseStyle$1(this.options.style);
|
|
5131
5135
|
}
|
|
5132
5136
|
static schema() {
|
|
@@ -5244,64 +5248,95 @@ class AttributeMisuse extends Rule {
|
|
|
5244
5248
|
function parsePattern(pattern) {
|
|
5245
5249
|
switch (pattern) {
|
|
5246
5250
|
case "kebabcase":
|
|
5247
|
-
return /^[a-z0-9-]
|
|
5251
|
+
return { regexp: /^[a-z0-9-]+$/, description: pattern };
|
|
5248
5252
|
case "camelcase":
|
|
5249
|
-
return /^[a-z][a-zA-Z0-9]
|
|
5253
|
+
return { regexp: /^[a-z][a-zA-Z0-9]+$/, description: pattern };
|
|
5250
5254
|
case "underscore":
|
|
5251
|
-
return /^[a-z0-9_]
|
|
5252
|
-
default:
|
|
5253
|
-
|
|
5255
|
+
return { regexp: /^[a-z0-9_]+$/, description: pattern };
|
|
5256
|
+
default: {
|
|
5257
|
+
const regexp = new RegExp(pattern);
|
|
5258
|
+
return { regexp, description: regexp.toString() };
|
|
5259
|
+
}
|
|
5254
5260
|
}
|
|
5255
5261
|
}
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5262
|
+
|
|
5263
|
+
function toArray$1(value) {
|
|
5264
|
+
return Array.isArray(value) ? value : [value];
|
|
5265
|
+
}
|
|
5266
|
+
class BasePatternRule extends Rule {
|
|
5267
|
+
/**
|
|
5268
|
+
* @param attr - Attribute holding the value.
|
|
5269
|
+
* @param options - Rule options with defaults expanded.
|
|
5270
|
+
*/
|
|
5271
|
+
constructor(attr, options) {
|
|
5272
|
+
super(options);
|
|
5273
|
+
const { pattern } = this.options;
|
|
5274
|
+
this.attr = attr;
|
|
5275
|
+
this.patterns = toArray$1(pattern).map((it) => parsePattern(it));
|
|
5276
|
+
}
|
|
5277
|
+
static schema() {
|
|
5278
|
+
return {
|
|
5279
|
+
pattern: {
|
|
5280
|
+
oneOf: [{ type: "array", items: { type: "string" }, minItems: 1 }, { type: "string" }]
|
|
5281
|
+
}
|
|
5282
|
+
};
|
|
5283
|
+
}
|
|
5284
|
+
description(context) {
|
|
5285
|
+
const { attr, patterns } = this;
|
|
5286
|
+
const { value } = context;
|
|
5287
|
+
const lead = patterns.length === 1 ? `The \`${attr}\` attribute value \`"${value}"\` does not match the configured pattern.` : `The \`${attr}\` attribute value \`"${value}"\` does not match either of the configured patterns.`;
|
|
5288
|
+
return [
|
|
5289
|
+
lead,
|
|
5290
|
+
"For consistency within the codebase the `${attr}` is required to match one or more of the following patterns:",
|
|
5291
|
+
"",
|
|
5292
|
+
...patterns.map((it) => `- \`${it.description}\``)
|
|
5293
|
+
].join("\n");
|
|
5294
|
+
}
|
|
5295
|
+
validateValue(node, value, location) {
|
|
5296
|
+
const { attr, patterns } = this;
|
|
5297
|
+
const matches = patterns.some((it) => it.regexp.test(value));
|
|
5298
|
+
if (matches) {
|
|
5299
|
+
return;
|
|
5263
5300
|
}
|
|
5264
|
-
|
|
5265
|
-
|
|
5301
|
+
const allowed = utils_naturalJoin.naturalJoin(patterns.map((it) => `"${it.description}"`));
|
|
5302
|
+
const message = patterns.length === 1 ? `${attr} "${value}" does not match the configured pattern ${allowed}` : `${attr} "${value}" does not match either of the configured patterns: ${allowed}`;
|
|
5303
|
+
this.report({
|
|
5304
|
+
node,
|
|
5305
|
+
message,
|
|
5306
|
+
location,
|
|
5307
|
+
context: {
|
|
5308
|
+
value
|
|
5309
|
+
}
|
|
5310
|
+
});
|
|
5266
5311
|
}
|
|
5267
5312
|
}
|
|
5268
5313
|
|
|
5269
|
-
const defaults$
|
|
5314
|
+
const defaults$p = {
|
|
5270
5315
|
pattern: "kebabcase"
|
|
5271
5316
|
};
|
|
5272
|
-
class ClassPattern extends
|
|
5317
|
+
class ClassPattern extends BasePatternRule {
|
|
5273
5318
|
constructor(options) {
|
|
5274
|
-
super({ ...defaults$
|
|
5275
|
-
this.pattern = parsePattern(this.options.pattern);
|
|
5319
|
+
super("class", { ...defaults$p, ...options });
|
|
5276
5320
|
}
|
|
5277
5321
|
static schema() {
|
|
5278
|
-
return
|
|
5279
|
-
pattern: {
|
|
5280
|
-
type: "string"
|
|
5281
|
-
}
|
|
5282
|
-
};
|
|
5322
|
+
return BasePatternRule.schema();
|
|
5283
5323
|
}
|
|
5284
|
-
documentation() {
|
|
5285
|
-
const pattern = describePattern(this.options.pattern);
|
|
5324
|
+
documentation(context) {
|
|
5286
5325
|
return {
|
|
5287
|
-
description:
|
|
5326
|
+
description: this.description(context),
|
|
5288
5327
|
url: "https://html-validate.org/rules/class-pattern.html"
|
|
5289
5328
|
};
|
|
5290
5329
|
}
|
|
5291
5330
|
setup() {
|
|
5292
5331
|
this.on("attr", (event) => {
|
|
5293
|
-
|
|
5332
|
+
const { target, key, value, valueLocation } = event;
|
|
5333
|
+
if (key.toLowerCase() !== "class") {
|
|
5294
5334
|
return;
|
|
5295
5335
|
}
|
|
5296
|
-
const classes = new DOMTokenList(
|
|
5297
|
-
classes.
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
const pattern = this.pattern.toString();
|
|
5301
|
-
const message = `Class "${cur}" does not match required pattern "${pattern}"`;
|
|
5302
|
-
this.report(event.target, message, location);
|
|
5303
|
-
}
|
|
5304
|
-
});
|
|
5336
|
+
const classes = new DOMTokenList(value, valueLocation);
|
|
5337
|
+
for (const { item, location } of classes.iterator()) {
|
|
5338
|
+
this.validateValue(target, item, location);
|
|
5339
|
+
}
|
|
5305
5340
|
});
|
|
5306
5341
|
}
|
|
5307
5342
|
}
|
|
@@ -5377,13 +5412,13 @@ class CloseOrder extends Rule {
|
|
|
5377
5412
|
}
|
|
5378
5413
|
}
|
|
5379
5414
|
|
|
5380
|
-
const defaults$
|
|
5415
|
+
const defaults$o = {
|
|
5381
5416
|
include: null,
|
|
5382
5417
|
exclude: null
|
|
5383
5418
|
};
|
|
5384
5419
|
class Deprecated extends Rule {
|
|
5385
5420
|
constructor(options) {
|
|
5386
|
-
super({ ...defaults$
|
|
5421
|
+
super({ ...defaults$o, ...options });
|
|
5387
5422
|
}
|
|
5388
5423
|
static schema() {
|
|
5389
5424
|
return {
|
|
@@ -5537,12 +5572,12 @@ let NoStyleTag$1 = class NoStyleTag extends Rule {
|
|
|
5537
5572
|
}
|
|
5538
5573
|
};
|
|
5539
5574
|
|
|
5540
|
-
const defaults$
|
|
5575
|
+
const defaults$n = {
|
|
5541
5576
|
style: "uppercase"
|
|
5542
5577
|
};
|
|
5543
5578
|
class DoctypeStyle extends Rule {
|
|
5544
5579
|
constructor(options) {
|
|
5545
|
-
super({ ...defaults$
|
|
5580
|
+
super({ ...defaults$n, ...options });
|
|
5546
5581
|
}
|
|
5547
5582
|
static schema() {
|
|
5548
5583
|
return {
|
|
@@ -5570,12 +5605,12 @@ class DoctypeStyle extends Rule {
|
|
|
5570
5605
|
}
|
|
5571
5606
|
}
|
|
5572
5607
|
|
|
5573
|
-
const defaults$
|
|
5608
|
+
const defaults$m = {
|
|
5574
5609
|
style: "lowercase"
|
|
5575
5610
|
};
|
|
5576
5611
|
class ElementCase extends Rule {
|
|
5577
5612
|
constructor(options) {
|
|
5578
|
-
super({ ...defaults$
|
|
5613
|
+
super({ ...defaults$m, ...options });
|
|
5579
5614
|
this.style = new CaseStyle(this.options.style, "element-case");
|
|
5580
5615
|
}
|
|
5581
5616
|
static schema() {
|
|
@@ -5635,14 +5670,14 @@ class ElementCase extends Rule {
|
|
|
5635
5670
|
}
|
|
5636
5671
|
}
|
|
5637
5672
|
|
|
5638
|
-
const defaults$
|
|
5673
|
+
const defaults$l = {
|
|
5639
5674
|
pattern: "^[a-z][a-z0-9\\-._]*-[a-z0-9\\-._]*$",
|
|
5640
5675
|
whitelist: [],
|
|
5641
5676
|
blacklist: []
|
|
5642
5677
|
};
|
|
5643
5678
|
class ElementName extends Rule {
|
|
5644
5679
|
constructor(options) {
|
|
5645
|
-
super({ ...defaults$
|
|
5680
|
+
super({ ...defaults$l, ...options });
|
|
5646
5681
|
this.pattern = new RegExp(this.options.pattern);
|
|
5647
5682
|
}
|
|
5648
5683
|
static schema() {
|
|
@@ -5679,7 +5714,7 @@ class ElementName extends Rule {
|
|
|
5679
5714
|
...context.blacklist.map((cur) => `- ${cur}`)
|
|
5680
5715
|
];
|
|
5681
5716
|
}
|
|
5682
|
-
if (context.pattern !== defaults$
|
|
5717
|
+
if (context.pattern !== defaults$l.pattern) {
|
|
5683
5718
|
return [
|
|
5684
5719
|
`<${context.tagName}> is not a valid element name. This project is configured to only allow names matching the following regular expression:`,
|
|
5685
5720
|
"",
|
|
@@ -6168,7 +6203,7 @@ class EmptyTitle extends Rule {
|
|
|
6168
6203
|
}
|
|
6169
6204
|
}
|
|
6170
6205
|
|
|
6171
|
-
const defaults$
|
|
6206
|
+
const defaults$k = {
|
|
6172
6207
|
allowArrayBrackets: true,
|
|
6173
6208
|
shared: ["radio", "button", "reset", "submit"]
|
|
6174
6209
|
};
|
|
@@ -6196,7 +6231,7 @@ function getDocumentation(context) {
|
|
|
6196
6231
|
}
|
|
6197
6232
|
class FormDupName extends Rule {
|
|
6198
6233
|
constructor(options) {
|
|
6199
|
-
super({ ...defaults$
|
|
6234
|
+
super({ ...defaults$k, ...options });
|
|
6200
6235
|
}
|
|
6201
6236
|
static schema() {
|
|
6202
6237
|
return {
|
|
@@ -6345,7 +6380,7 @@ class FormDupName extends Rule {
|
|
|
6345
6380
|
}
|
|
6346
6381
|
}
|
|
6347
6382
|
|
|
6348
|
-
const defaults$
|
|
6383
|
+
const defaults$j = {
|
|
6349
6384
|
allowMultipleH1: false,
|
|
6350
6385
|
minInitialRank: "h1",
|
|
6351
6386
|
sectioningRoots: ["dialog", '[role="dialog"]', '[role="alertdialog"]']
|
|
@@ -6374,7 +6409,7 @@ function parseMaxInitial(value) {
|
|
|
6374
6409
|
}
|
|
6375
6410
|
class HeadingLevel extends Rule {
|
|
6376
6411
|
constructor(options) {
|
|
6377
|
-
super({ ...defaults$
|
|
6412
|
+
super({ ...defaults$j, ...options });
|
|
6378
6413
|
this.stack = [];
|
|
6379
6414
|
this.minInitialRank = parseMaxInitial(this.options.minInitialRank);
|
|
6380
6415
|
this.sectionRoots = this.options.sectioningRoots.map((it) => new Pattern(it));
|
|
@@ -6610,43 +6645,35 @@ class HiddenFocusable extends Rule {
|
|
|
6610
6645
|
}
|
|
6611
6646
|
}
|
|
6612
6647
|
|
|
6613
|
-
const defaults$
|
|
6648
|
+
const defaults$i = {
|
|
6614
6649
|
pattern: "kebabcase"
|
|
6615
6650
|
};
|
|
6616
|
-
class IdPattern extends
|
|
6651
|
+
class IdPattern extends BasePatternRule {
|
|
6617
6652
|
constructor(options) {
|
|
6618
|
-
super({ ...defaults$
|
|
6619
|
-
this.pattern = parsePattern(this.options.pattern);
|
|
6653
|
+
super("id", { ...defaults$i, ...options });
|
|
6620
6654
|
}
|
|
6621
6655
|
static schema() {
|
|
6622
|
-
return
|
|
6623
|
-
pattern: {
|
|
6624
|
-
type: "string"
|
|
6625
|
-
}
|
|
6626
|
-
};
|
|
6656
|
+
return BasePatternRule.schema();
|
|
6627
6657
|
}
|
|
6628
|
-
documentation() {
|
|
6629
|
-
const pattern = describePattern(this.options.pattern);
|
|
6658
|
+
documentation(context) {
|
|
6630
6659
|
return {
|
|
6631
|
-
description:
|
|
6660
|
+
description: this.description(context),
|
|
6632
6661
|
url: "https://html-validate.org/rules/id-pattern.html"
|
|
6633
6662
|
};
|
|
6634
6663
|
}
|
|
6635
6664
|
setup() {
|
|
6636
6665
|
this.on("attr", (event) => {
|
|
6637
|
-
|
|
6638
|
-
if (
|
|
6666
|
+
const { target, key, value, valueLocation } = event;
|
|
6667
|
+
if (key.toLowerCase() !== "id") {
|
|
6639
6668
|
return;
|
|
6640
6669
|
}
|
|
6641
|
-
if (
|
|
6670
|
+
if (value instanceof DynamicValue) {
|
|
6642
6671
|
return;
|
|
6643
6672
|
}
|
|
6644
|
-
if (
|
|
6645
|
-
|
|
6646
|
-
const pattern = this.pattern.toString();
|
|
6647
|
-
const message = `ID "${value}" does not match required pattern "${pattern}"`;
|
|
6648
|
-
this.report(event.target, message, event.valueLocation);
|
|
6673
|
+
if (value === null) {
|
|
6674
|
+
return;
|
|
6649
6675
|
}
|
|
6676
|
+
this.validateValue(target, value, valueLocation);
|
|
6650
6677
|
});
|
|
6651
6678
|
}
|
|
6652
6679
|
}
|
|
@@ -6885,7 +6912,7 @@ class InputMissingLabel extends Rule {
|
|
|
6885
6912
|
});
|
|
6886
6913
|
}
|
|
6887
6914
|
validateInput(root, elem) {
|
|
6888
|
-
if (
|
|
6915
|
+
if (!inAccessibilityTree(elem)) {
|
|
6889
6916
|
return;
|
|
6890
6917
|
}
|
|
6891
6918
|
if (isIgnored(elem)) {
|
|
@@ -6918,7 +6945,7 @@ class InputMissingLabel extends Rule {
|
|
|
6918
6945
|
* Reports error if none of the labels are accessible.
|
|
6919
6946
|
*/
|
|
6920
6947
|
validateLabel(root, elem, labels) {
|
|
6921
|
-
const visible = labels.filter(
|
|
6948
|
+
const visible = labels.filter(inAccessibilityTree);
|
|
6922
6949
|
if (visible.length === 0) {
|
|
6923
6950
|
this.report(elem, `<${elem.tagName}> element has <label> but <label> element is hidden`);
|
|
6924
6951
|
return;
|
|
@@ -6928,10 +6955,6 @@ class InputMissingLabel extends Rule {
|
|
|
6928
6955
|
}
|
|
6929
6956
|
}
|
|
6930
6957
|
}
|
|
6931
|
-
function isVisible(elem) {
|
|
6932
|
-
const hidden = isHTMLHidden(elem) || isAriaHidden(elem);
|
|
6933
|
-
return !hidden;
|
|
6934
|
-
}
|
|
6935
6958
|
function findLabelById(root, id) {
|
|
6936
6959
|
if (!id)
|
|
6937
6960
|
return [];
|
|
@@ -6948,12 +6971,12 @@ function findLabelByParent(el) {
|
|
|
6948
6971
|
return [];
|
|
6949
6972
|
}
|
|
6950
6973
|
|
|
6951
|
-
const defaults$
|
|
6974
|
+
const defaults$h = {
|
|
6952
6975
|
maxlength: 70
|
|
6953
6976
|
};
|
|
6954
6977
|
class LongTitle extends Rule {
|
|
6955
6978
|
constructor(options) {
|
|
6956
|
-
super({ ...defaults$
|
|
6979
|
+
super({ ...defaults$h, ...options });
|
|
6957
6980
|
this.maxlength = this.options.maxlength;
|
|
6958
6981
|
}
|
|
6959
6982
|
static schema() {
|
|
@@ -6982,12 +7005,12 @@ class LongTitle extends Rule {
|
|
|
6982
7005
|
}
|
|
6983
7006
|
}
|
|
6984
7007
|
|
|
6985
|
-
const defaults$
|
|
7008
|
+
const defaults$g = {
|
|
6986
7009
|
allowLongDelay: false
|
|
6987
7010
|
};
|
|
6988
7011
|
class MetaRefresh extends Rule {
|
|
6989
7012
|
constructor(options) {
|
|
6990
|
-
super({ ...defaults$
|
|
7013
|
+
super({ ...defaults$g, ...options });
|
|
6991
7014
|
}
|
|
6992
7015
|
documentation() {
|
|
6993
7016
|
return {
|
|
@@ -7175,6 +7198,45 @@ class MultipleLabeledControls extends Rule {
|
|
|
7175
7198
|
}
|
|
7176
7199
|
}
|
|
7177
7200
|
|
|
7201
|
+
const defaults$f = {
|
|
7202
|
+
pattern: "camelcase"
|
|
7203
|
+
};
|
|
7204
|
+
class NamePattern extends BasePatternRule {
|
|
7205
|
+
constructor(options) {
|
|
7206
|
+
super("name", { ...defaults$f, ...options });
|
|
7207
|
+
}
|
|
7208
|
+
static schema() {
|
|
7209
|
+
return BasePatternRule.schema();
|
|
7210
|
+
}
|
|
7211
|
+
documentation(context) {
|
|
7212
|
+
return {
|
|
7213
|
+
description: this.description(context),
|
|
7214
|
+
url: "https://html-validate.org/rules/name-pattern.html"
|
|
7215
|
+
};
|
|
7216
|
+
}
|
|
7217
|
+
setup() {
|
|
7218
|
+
this.on("attr", (event) => {
|
|
7219
|
+
var _a;
|
|
7220
|
+
const { target, key, value, valueLocation } = event;
|
|
7221
|
+
const { meta } = target;
|
|
7222
|
+
if (!((_a = meta == null ? void 0 : meta.formAssociated) == null ? void 0 : _a.listed)) {
|
|
7223
|
+
return;
|
|
7224
|
+
}
|
|
7225
|
+
if (key.toLowerCase() !== "name") {
|
|
7226
|
+
return;
|
|
7227
|
+
}
|
|
7228
|
+
if (value instanceof DynamicValue) {
|
|
7229
|
+
return;
|
|
7230
|
+
}
|
|
7231
|
+
if (value === null) {
|
|
7232
|
+
return;
|
|
7233
|
+
}
|
|
7234
|
+
const name = value.endsWith("[]") ? value.slice(0, -2) : value;
|
|
7235
|
+
this.validateValue(target, name, valueLocation);
|
|
7236
|
+
});
|
|
7237
|
+
}
|
|
7238
|
+
}
|
|
7239
|
+
|
|
7178
7240
|
const abstractRoles = [
|
|
7179
7241
|
"command",
|
|
7180
7242
|
"composite",
|
|
@@ -10156,6 +10218,7 @@ const bundledRules = {
|
|
|
10156
10218
|
"meta-refresh": MetaRefresh,
|
|
10157
10219
|
"missing-doctype": MissingDoctype,
|
|
10158
10220
|
"multiple-labeled-controls": MultipleLabeledControls,
|
|
10221
|
+
"name-pattern": NamePattern,
|
|
10159
10222
|
"no-abstract-role": NoAbstractRole,
|
|
10160
10223
|
"no-autoplay": NoAutoplay,
|
|
10161
10224
|
"no-conditional-comment": NoConditionalComment,
|
|
@@ -12596,7 +12659,7 @@ class HtmlValidate {
|
|
|
12596
12659
|
}
|
|
12597
12660
|
|
|
12598
12661
|
const name = "html-validate";
|
|
12599
|
-
const version = "8.
|
|
12662
|
+
const version = "8.17.1";
|
|
12600
12663
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
12601
12664
|
|
|
12602
12665
|
function definePlugin(plugin) {
|