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.
package/dist/cjs/core.js CHANGED
@@ -1517,6 +1517,7 @@ var State = /* @__PURE__ */ ((State2) => {
1517
1517
  State2[State2["CDATA"] = 6] = "CDATA";
1518
1518
  State2[State2["SCRIPT"] = 7] = "SCRIPT";
1519
1519
  State2[State2["STYLE"] = 8] = "STYLE";
1520
+ State2[State2["TEXTAREA"] = 9] = "TEXTAREA";
1520
1521
  return State2;
1521
1522
  })(State || {});
1522
1523
 
@@ -1524,6 +1525,7 @@ var ContentModel = /* @__PURE__ */ ((ContentModel2) => {
1524
1525
  ContentModel2[ContentModel2["TEXT"] = 1] = "TEXT";
1525
1526
  ContentModel2[ContentModel2["SCRIPT"] = 2] = "SCRIPT";
1526
1527
  ContentModel2[ContentModel2["STYLE"] = 3] = "STYLE";
1528
+ ContentModel2[ContentModel2["TEXTAREA"] = 4] = "TEXTAREA";
1527
1529
  return ContentModel2;
1528
1530
  })(ContentModel || {});
1529
1531
  class Context {
@@ -2759,6 +2761,22 @@ class HtmlElement extends DOMNode {
2759
2761
  }
2760
2762
  return this.cacheSet(TABINDEX, parsed);
2761
2763
  }
2764
+ /**
2765
+ * Read-only property with the type of the text content of this
2766
+ * element.
2767
+ *
2768
+ * @internal
2769
+ */
2770
+ get textType() {
2771
+ const tagName = this.tagName.toLowerCase();
2772
+ if (tagName === "script") {
2773
+ return "script";
2774
+ } else if (tagName === "style") {
2775
+ return "css";
2776
+ } else {
2777
+ return "text";
2778
+ }
2779
+ }
2762
2780
  /**
2763
2781
  * Get a list of all attributes on this node.
2764
2782
  */
@@ -4702,6 +4720,8 @@ const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
4702
4720
  const MATCH_SCRIPT_END = /^<(\/)(script)/;
4703
4721
  const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
4704
4722
  const MATCH_STYLE_END = /^<(\/)(style)/;
4723
+ const MATCH_TEXTAREA_DATA = /^[^]*?(?=<\/textarea)/;
4724
+ const MATCH_TEXTAREA_END = /^<(\/)(textarea)/;
4705
4725
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4706
4726
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4707
4727
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
@@ -4744,6 +4764,9 @@ class Lexer {
4744
4764
  case State.STYLE:
4745
4765
  yield* this.tokenizeStyle(context);
4746
4766
  break;
4767
+ case State.TEXTAREA:
4768
+ yield* this.tokenizeTextarea(context);
4769
+ break;
4747
4770
  /* istanbul ignore next: sanity check: should not happen unless adding new states */
4748
4771
  default:
4749
4772
  this.unhandled(context);
@@ -4816,6 +4839,8 @@ class Lexer {
4816
4839
  context.contentModel = ContentModel.SCRIPT;
4817
4840
  } else if (data[0] === "<style") {
4818
4841
  context.contentModel = ContentModel.STYLE;
4842
+ } else if (data[0] === "<textarea") {
4843
+ context.contentModel = ContentModel.TEXTAREA;
4819
4844
  } else {
4820
4845
  context.contentModel = ContentModel.TEXT;
4821
4846
  }
@@ -4851,21 +4876,28 @@ class Lexer {
4851
4876
  *tokenizeTag(context) {
4852
4877
  function nextState(token) {
4853
4878
  const tagCloseToken = token;
4879
+ const selfClosed = tagCloseToken && !tagCloseToken.data[0].startsWith("/");
4854
4880
  switch (context.contentModel) {
4855
4881
  case ContentModel.TEXT:
4856
4882
  return State.TEXT;
4857
4883
  case ContentModel.SCRIPT:
4858
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4884
+ if (selfClosed) {
4859
4885
  return State.SCRIPT;
4860
4886
  } else {
4861
4887
  return State.TEXT;
4862
4888
  }
4863
4889
  case ContentModel.STYLE:
4864
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4890
+ if (selfClosed) {
4865
4891
  return State.STYLE;
4866
4892
  } else {
4867
4893
  return State.TEXT;
4868
4894
  }
4895
+ case ContentModel.TEXTAREA:
4896
+ if (selfClosed) {
4897
+ return State.TEXTAREA;
4898
+ } else {
4899
+ return State.TEXT;
4900
+ }
4869
4901
  }
4870
4902
  }
4871
4903
  yield* this.match(
@@ -4930,6 +4962,16 @@ class Lexer {
4930
4962
  "expected </style>"
4931
4963
  );
4932
4964
  }
4965
+ *tokenizeTextarea(context) {
4966
+ yield* this.match(
4967
+ context,
4968
+ [
4969
+ [MATCH_TEXTAREA_END, State.TAG, TokenType.TAG_OPEN],
4970
+ [MATCH_TEXTAREA_DATA, State.TEXTAREA, TokenType.TEXT]
4971
+ ],
4972
+ "expected </textarea>"
4973
+ );
4974
+ }
4933
4975
  }
4934
4976
 
4935
4977
  const whitespace = /(\s+)/;
@@ -8151,6 +8193,9 @@ class NoRawCharacters extends Rule {
8151
8193
  setup() {
8152
8194
  this.on("element:ready", (event) => {
8153
8195
  const node = event.target;
8196
+ if (node.textType !== "text") {
8197
+ return;
8198
+ }
8154
8199
  for (const child of node.childNodes) {
8155
8200
  if (child.nodeType !== NodeType.TEXT_NODE) {
8156
8201
  continue;
@@ -9443,6 +9488,9 @@ class UnknownCharReference extends Rule {
9443
9488
  setup() {
9444
9489
  this.on("element:ready", (event) => {
9445
9490
  const node = event.target;
9491
+ if (node.textType !== "text") {
9492
+ return;
9493
+ }
9446
9494
  for (const child of node.childNodes) {
9447
9495
  if (child.nodeType !== NodeType.TEXT_NODE) {
9448
9496
  continue;
@@ -11803,7 +11851,7 @@ class EventHandler {
11803
11851
  }
11804
11852
 
11805
11853
  const name = "html-validate";
11806
- const version = "10.0.0";
11854
+ const version = "10.1.1";
11807
11855
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11808
11856
 
11809
11857
  function freeze(src) {
@@ -12107,6 +12155,8 @@ class Parser {
12107
12155
  break;
12108
12156
  case TokenType.TEXT:
12109
12157
  case TokenType.TEMPLATING:
12158
+ case TokenType.SCRIPT:
12159
+ case TokenType.STYLE:
12110
12160
  this.appendText(token.data[0], token.location);
12111
12161
  break;
12112
12162
  case TokenType.EOF:
@@ -14200,7 +14250,7 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
14200
14250
  var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
14201
14251
 
14202
14252
  const engines = {
14203
- node: ">= 20.6.0"
14253
+ node: "^20.19.0 || >= 22.12.0"
14204
14254
  };
14205
14255
 
14206
14256
  var workerPath = "./jest-worker.js";