html-validate 10.0.0 → 10.1.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.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.10"
8
+ "packageVersion": "7.53.0"
9
9
  }
10
10
  ]
11
11
  }
package/dist/esm/core.js CHANGED
@@ -1508,6 +1508,7 @@ var State = /* @__PURE__ */ ((State2) => {
1508
1508
  State2[State2["CDATA"] = 6] = "CDATA";
1509
1509
  State2[State2["SCRIPT"] = 7] = "SCRIPT";
1510
1510
  State2[State2["STYLE"] = 8] = "STYLE";
1511
+ State2[State2["TEXTAREA"] = 9] = "TEXTAREA";
1511
1512
  return State2;
1512
1513
  })(State || {});
1513
1514
 
@@ -1515,6 +1516,7 @@ var ContentModel = /* @__PURE__ */ ((ContentModel2) => {
1515
1516
  ContentModel2[ContentModel2["TEXT"] = 1] = "TEXT";
1516
1517
  ContentModel2[ContentModel2["SCRIPT"] = 2] = "SCRIPT";
1517
1518
  ContentModel2[ContentModel2["STYLE"] = 3] = "STYLE";
1519
+ ContentModel2[ContentModel2["TEXTAREA"] = 4] = "TEXTAREA";
1518
1520
  return ContentModel2;
1519
1521
  })(ContentModel || {});
1520
1522
  class Context {
@@ -2750,6 +2752,22 @@ class HtmlElement extends DOMNode {
2750
2752
  }
2751
2753
  return this.cacheSet(TABINDEX, parsed);
2752
2754
  }
2755
+ /**
2756
+ * Read-only property with the type of the text content of this
2757
+ * element.
2758
+ *
2759
+ * @internal
2760
+ */
2761
+ get textType() {
2762
+ const tagName = this.tagName.toLowerCase();
2763
+ if (tagName === "script") {
2764
+ return "script";
2765
+ } else if (tagName === "style") {
2766
+ return "css";
2767
+ } else {
2768
+ return "text";
2769
+ }
2770
+ }
2753
2771
  /**
2754
2772
  * Get a list of all attributes on this node.
2755
2773
  */
@@ -4693,6 +4711,8 @@ const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
4693
4711
  const MATCH_SCRIPT_END = /^<(\/)(script)/;
4694
4712
  const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
4695
4713
  const MATCH_STYLE_END = /^<(\/)(style)/;
4714
+ const MATCH_TEXTAREA_DATA = /^[^]*?(?=<\/textarea)/;
4715
+ const MATCH_TEXTAREA_END = /^<(\/)(textarea)/;
4696
4716
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4697
4717
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4698
4718
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
@@ -4735,6 +4755,9 @@ class Lexer {
4735
4755
  case State.STYLE:
4736
4756
  yield* this.tokenizeStyle(context);
4737
4757
  break;
4758
+ case State.TEXTAREA:
4759
+ yield* this.tokenizeTextarea(context);
4760
+ break;
4738
4761
  /* istanbul ignore next: sanity check: should not happen unless adding new states */
4739
4762
  default:
4740
4763
  this.unhandled(context);
@@ -4807,6 +4830,8 @@ class Lexer {
4807
4830
  context.contentModel = ContentModel.SCRIPT;
4808
4831
  } else if (data[0] === "<style") {
4809
4832
  context.contentModel = ContentModel.STYLE;
4833
+ } else if (data[0] === "<textarea") {
4834
+ context.contentModel = ContentModel.TEXTAREA;
4810
4835
  } else {
4811
4836
  context.contentModel = ContentModel.TEXT;
4812
4837
  }
@@ -4842,21 +4867,28 @@ class Lexer {
4842
4867
  *tokenizeTag(context) {
4843
4868
  function nextState(token) {
4844
4869
  const tagCloseToken = token;
4870
+ const selfClosed = tagCloseToken && !tagCloseToken.data[0].startsWith("/");
4845
4871
  switch (context.contentModel) {
4846
4872
  case ContentModel.TEXT:
4847
4873
  return State.TEXT;
4848
4874
  case ContentModel.SCRIPT:
4849
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4875
+ if (selfClosed) {
4850
4876
  return State.SCRIPT;
4851
4877
  } else {
4852
4878
  return State.TEXT;
4853
4879
  }
4854
4880
  case ContentModel.STYLE:
4855
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4881
+ if (selfClosed) {
4856
4882
  return State.STYLE;
4857
4883
  } else {
4858
4884
  return State.TEXT;
4859
4885
  }
4886
+ case ContentModel.TEXTAREA:
4887
+ if (selfClosed) {
4888
+ return State.TEXTAREA;
4889
+ } else {
4890
+ return State.TEXT;
4891
+ }
4860
4892
  }
4861
4893
  }
4862
4894
  yield* this.match(
@@ -4921,6 +4953,16 @@ class Lexer {
4921
4953
  "expected </style>"
4922
4954
  );
4923
4955
  }
4956
+ *tokenizeTextarea(context) {
4957
+ yield* this.match(
4958
+ context,
4959
+ [
4960
+ [MATCH_TEXTAREA_END, State.TAG, TokenType.TAG_OPEN],
4961
+ [MATCH_TEXTAREA_DATA, State.TEXTAREA, TokenType.TEXT]
4962
+ ],
4963
+ "expected </textarea>"
4964
+ );
4965
+ }
4924
4966
  }
4925
4967
 
4926
4968
  const whitespace = /(\s+)/;
@@ -8142,6 +8184,9 @@ class NoRawCharacters extends Rule {
8142
8184
  setup() {
8143
8185
  this.on("element:ready", (event) => {
8144
8186
  const node = event.target;
8187
+ if (node.textType !== "text") {
8188
+ return;
8189
+ }
8145
8190
  for (const child of node.childNodes) {
8146
8191
  if (child.nodeType !== NodeType.TEXT_NODE) {
8147
8192
  continue;
@@ -9434,6 +9479,9 @@ class UnknownCharReference extends Rule {
9434
9479
  setup() {
9435
9480
  this.on("element:ready", (event) => {
9436
9481
  const node = event.target;
9482
+ if (node.textType !== "text") {
9483
+ return;
9484
+ }
9437
9485
  for (const child of node.childNodes) {
9438
9486
  if (child.nodeType !== NodeType.TEXT_NODE) {
9439
9487
  continue;
@@ -11794,7 +11842,7 @@ class EventHandler {
11794
11842
  }
11795
11843
 
11796
11844
  const name = "html-validate";
11797
- const version = "10.0.0";
11845
+ const version = "10.1.1";
11798
11846
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11799
11847
 
11800
11848
  function freeze(src) {
@@ -12098,6 +12146,8 @@ class Parser {
12098
12146
  break;
12099
12147
  case TokenType.TEXT:
12100
12148
  case TokenType.TEMPLATING:
12149
+ case TokenType.SCRIPT:
12150
+ case TokenType.STYLE:
12101
12151
  this.appendText(token.data[0], token.location);
12102
12152
  break;
12103
12153
  case TokenType.EOF:
@@ -14191,7 +14241,7 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
14191
14241
  var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
14192
14242
 
14193
14243
  const engines = {
14194
- node: ">= 20.6.0"
14244
+ node: "^20.19.0 || >= 22.12.0"
14195
14245
  };
14196
14246
 
14197
14247
  var workerPath = "./jest-worker.js";