html-validate 9.2.0 → 9.2.2

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/es/core.js CHANGED
@@ -436,7 +436,7 @@ class UserError extends NestedError {
436
436
  */
437
437
  /* istanbul ignore next: default implementation */
438
438
  prettyFormat() {
439
- return undefined;
439
+ return void 0;
440
440
  }
441
441
  }
442
442
 
@@ -943,7 +943,7 @@ const ajvRegexpValidate = function(data, dataCxt) {
943
943
  ajvRegexpValidate.errors = [
944
944
  {
945
945
  instancePath: dataCxt?.instancePath,
946
- schemaPath: undefined,
946
+ schemaPath: void 0,
947
947
  keyword: "type",
948
948
  message: "should be a regular expression",
949
949
  params: {
@@ -970,7 +970,7 @@ const ajvFunctionValidate = function(data, dataCxt) {
970
970
  /* istanbul ignore next */
971
971
  dataCxt?.instancePath
972
972
  ),
973
- schemaPath: undefined,
973
+ schemaPath: void 0,
974
974
  keyword: "type",
975
975
  message: "should be a function",
976
976
  params: {
@@ -1025,7 +1025,7 @@ function isSet(value) {
1025
1025
  return typeof value !== "undefined";
1026
1026
  }
1027
1027
  function flag(value) {
1028
- return value ? true : undefined;
1028
+ return value ? true : void 0;
1029
1029
  }
1030
1030
  function stripUndefined(src) {
1031
1031
  const entries = Object.entries(src).filter(([, value]) => isSet(value));
@@ -1035,8 +1035,8 @@ function migrateSingleAttribute(src, key) {
1035
1035
  const result = {};
1036
1036
  result.deprecated = flag(src.deprecatedAttributes?.includes(key));
1037
1037
  result.required = flag(src.requiredAttributes?.includes(key));
1038
- result.omit = undefined;
1039
- const attr = src.attributes ? src.attributes[key] : undefined;
1038
+ result.omit = void 0;
1039
+ const attr = src.attributes ? src.attributes[key] : void 0;
1040
1040
  if (typeof attr === "undefined") {
1041
1041
  return stripUndefined(result);
1042
1042
  }
@@ -1092,7 +1092,7 @@ function migrateElement(src) {
1092
1092
  const result = {
1093
1093
  ...src,
1094
1094
  ...{
1095
- formAssociated: undefined
1095
+ formAssociated: void 0
1096
1096
  },
1097
1097
  attributes: migrateAttributes(src),
1098
1098
  textContent: src.textContent,
@@ -1630,7 +1630,7 @@ class DOMNode {
1630
1630
  if (this.cache) {
1631
1631
  return this.cache.get(key);
1632
1632
  } else {
1633
- return undefined;
1633
+ return void 0;
1634
1634
  }
1635
1635
  }
1636
1636
  cacheSet(key, value) {
@@ -1890,7 +1890,7 @@ function parseCombinator(combinator, pattern) {
1890
1890
  return 5 /* SCOPE */;
1891
1891
  }
1892
1892
  switch (combinator) {
1893
- case undefined:
1893
+ case void 0:
1894
1894
  case null:
1895
1895
  case "":
1896
1896
  return 1 /* DESCENDANT */;
@@ -2122,7 +2122,7 @@ class AttrMatcher extends Matcher {
2122
2122
  const attr = node.getAttribute(this.key, true);
2123
2123
  return attr.some((cur) => {
2124
2124
  switch (this.op) {
2125
- case undefined:
2125
+ case void 0:
2126
2126
  return true;
2127
2127
  /* attribute exists */
2128
2128
  case "=":
@@ -2595,7 +2595,7 @@ class HtmlElement extends DOMNode {
2595
2595
  */
2596
2596
  get role() {
2597
2597
  const cached = this.cacheGet(ROLE);
2598
- if (cached !== undefined) {
2598
+ if (cached !== void 0) {
2599
2599
  return cached;
2600
2600
  }
2601
2601
  const role = this.getAttribute("role");
@@ -2653,7 +2653,7 @@ class HtmlElement extends DOMNode {
2653
2653
  */
2654
2654
  get tabIndex() {
2655
2655
  const cached = this.cacheGet(TABINDEX);
2656
- if (cached !== undefined) {
2656
+ if (cached !== void 0) {
2657
2657
  return cached;
2658
2658
  }
2659
2659
  const tabindex = this.getAttribute("tabindex");
@@ -3676,9 +3676,7 @@ function classifyNodeText(node, options = {}) {
3676
3676
  return node.cacheSet(cacheKey, 0 /* EMPTY_TEXT */);
3677
3677
  }
3678
3678
  const text = findTextNodes(node, {
3679
- ...options,
3680
- ignoreHiddenRoot: false
3681
- });
3679
+ ...options});
3682
3680
  if (text.some((cur) => cur.isDynamic)) {
3683
3681
  return node.cacheSet(cacheKey, 1 /* DYNAMIC_TEXT */);
3684
3682
  }
@@ -4600,7 +4598,7 @@ const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
4600
4598
  const MATCH_DOCTYPE_VALUE = /^[^>]+/;
4601
4599
  const MATCH_DOCTYPE_CLOSE = /^>/;
4602
4600
  const MATCH_XML_TAG = /^<\?xml.*?\?>\s+/;
4603
- const MATCH_TAG_OPEN = /^<(\/?)([a-zA-Z0-9\-:]+)/;
4601
+ const MATCH_TAG_OPEN = /^<(\/?)([a-zA-Z0-9\-_:]+)/;
4604
4602
  const MATCH_TAG_CLOSE = /^\/?>/;
4605
4603
  const MATCH_TEXT = /^[^]*?(?=(?:[ \t]*(?:\r\n|\r|\n)|<[^ ]|$))/;
4606
4604
  const MATCH_TEMPLATING = /^(?:<%.*?%>|<\?.*?\?>|<\$.*?\$>)/s;
@@ -8700,6 +8698,22 @@ const supportSri = {
8700
8698
  link: "href",
8701
8699
  script: "src"
8702
8700
  };
8701
+ const supportedRel = ["stylesheet", "preload", "modulepreload"];
8702
+ const supportedPreload = ["style", "script"];
8703
+ function linkSupportsSri(node) {
8704
+ const rel = node.getAttribute("rel");
8705
+ if (typeof rel?.value !== "string") {
8706
+ return false;
8707
+ }
8708
+ if (!supportedRel.includes(rel.value)) {
8709
+ return false;
8710
+ }
8711
+ if (rel.value === "preload") {
8712
+ const as = node.getAttribute("as");
8713
+ return typeof as?.value === "string" && supportedPreload.includes(as.value);
8714
+ }
8715
+ return true;
8716
+ }
8703
8717
  class RequireSri extends Rule {
8704
8718
  target;
8705
8719
  constructor(options) {
@@ -8766,6 +8780,9 @@ class RequireSri extends Rule {
8766
8780
  return Object.keys(supportSri).includes(node.tagName);
8767
8781
  }
8768
8782
  needSri(node) {
8783
+ if (node.is("link") && !linkSupportsSri(node)) {
8784
+ return false;
8785
+ }
8769
8786
  const attr = this.elementSourceAttr(node);
8770
8787
  if (!attr) {
8771
8788
  return false;
@@ -11939,7 +11956,7 @@ class Parser {
11939
11956
  */
11940
11957
  getAttributeLocation(key, value) {
11941
11958
  const begin = key.location;
11942
- const end = value && value.type === TokenType.ATTR_VALUE ? value.location : undefined;
11959
+ const end = value && value.type === TokenType.ATTR_VALUE ? value.location : void 0;
11943
11960
  return {
11944
11961
  filename: begin.filename,
11945
11962
  line: begin.line,
@@ -11978,8 +11995,8 @@ class Parser {
11978
11995
  actionOffset,
11979
11996
  actionOffset + action.length
11980
11997
  );
11981
- const optionsLocation = data ? sliceLocation(token.location, optionsOffset, optionsOffset + data.length) : undefined;
11982
- const commentLocation = comment ? sliceLocation(token.location, commentOffset, commentOffset + comment.length) : undefined;
11998
+ const optionsLocation = data ? sliceLocation(token.location, optionsOffset, optionsOffset + data.length) : void 0;
11999
+ const commentLocation = comment ? sliceLocation(token.location, commentOffset, commentOffset + comment.length) : void 0;
11983
12000
  this.trigger("directive", {
11984
12001
  action,
11985
12002
  data,
@@ -12920,13 +12937,13 @@ function isConfigData(value) {
12920
12937
  class HtmlValidate {
12921
12938
  configLoader;
12922
12939
  constructor(arg) {
12923
- const [loader, config] = arg instanceof ConfigLoader ? [arg, undefined] : [undefined, arg];
12940
+ const [loader, config] = arg instanceof ConfigLoader ? [arg, void 0] : [void 0, arg];
12924
12941
  this.configLoader = loader ?? new StaticConfigLoader(config);
12925
12942
  }
12926
12943
  /* eslint-enable @typescript-eslint/unified-signatures */
12927
12944
  validateString(str, arg1, arg2, arg3) {
12928
12945
  const filename = typeof arg1 === "string" ? arg1 : "inline";
12929
- const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined;
12946
+ const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : void 0;
12930
12947
  const hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3;
12931
12948
  const source = {
12932
12949
  data: str,
@@ -12941,7 +12958,7 @@ class HtmlValidate {
12941
12958
  /* eslint-enable @typescript-eslint/unified-signatures */
12942
12959
  validateStringSync(str, arg1, arg2, arg3) {
12943
12960
  const filename = typeof arg1 === "string" ? arg1 : "inline";
12944
- const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : undefined;
12961
+ const options = isConfigData(arg1) ? arg1 : isConfigData(arg2) ? arg2 : void 0;
12945
12962
  const hooks = isSourceHooks(arg1) ? arg1 : isSourceHooks(arg2) ? arg2 : arg3;
12946
12963
  const source = {
12947
12964
  data: str,
@@ -13322,7 +13339,7 @@ class HtmlValidate {
13322
13339
  }
13323
13340
 
13324
13341
  const name = "html-validate";
13325
- const version = "9.2.0";
13342
+ const version = "9.2.2";
13326
13343
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
13327
13344
 
13328
13345
  function definePlugin(plugin) {