html-validate 10.0.0 → 10.1.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/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 {
@@ -4702,6 +4704,8 @@ const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
4702
4704
  const MATCH_SCRIPT_END = /^<(\/)(script)/;
4703
4705
  const MATCH_STYLE_DATA = /^[^]*?(?=<\/style)/;
4704
4706
  const MATCH_STYLE_END = /^<(\/)(style)/;
4707
+ const MATCH_TEXTAREA_DATA = /^[^]*?(?=<\/textarea)/;
4708
+ const MATCH_TEXTAREA_END = /^<(\/)(textarea)/;
4705
4709
  const MATCH_DIRECTIVE = /^(<!--\s*\[html-validate-)([a-z0-9-]+)(\s*)(.*?)(]?\s*-->)/;
4706
4710
  const MATCH_COMMENT = /^<!--([^]*?)-->/;
4707
4711
  const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
@@ -4744,6 +4748,9 @@ class Lexer {
4744
4748
  case State.STYLE:
4745
4749
  yield* this.tokenizeStyle(context);
4746
4750
  break;
4751
+ case State.TEXTAREA:
4752
+ yield* this.tokenizeTextarea(context);
4753
+ break;
4747
4754
  /* istanbul ignore next: sanity check: should not happen unless adding new states */
4748
4755
  default:
4749
4756
  this.unhandled(context);
@@ -4816,6 +4823,8 @@ class Lexer {
4816
4823
  context.contentModel = ContentModel.SCRIPT;
4817
4824
  } else if (data[0] === "<style") {
4818
4825
  context.contentModel = ContentModel.STYLE;
4826
+ } else if (data[0] === "<textarea") {
4827
+ context.contentModel = ContentModel.TEXTAREA;
4819
4828
  } else {
4820
4829
  context.contentModel = ContentModel.TEXT;
4821
4830
  }
@@ -4851,21 +4860,28 @@ class Lexer {
4851
4860
  *tokenizeTag(context) {
4852
4861
  function nextState(token) {
4853
4862
  const tagCloseToken = token;
4863
+ const selfClosed = tagCloseToken && !tagCloseToken.data[0].startsWith("/");
4854
4864
  switch (context.contentModel) {
4855
4865
  case ContentModel.TEXT:
4856
4866
  return State.TEXT;
4857
4867
  case ContentModel.SCRIPT:
4858
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4868
+ if (selfClosed) {
4859
4869
  return State.SCRIPT;
4860
4870
  } else {
4861
4871
  return State.TEXT;
4862
4872
  }
4863
4873
  case ContentModel.STYLE:
4864
- if (tagCloseToken && !tagCloseToken.data[0].startsWith("/")) {
4874
+ if (selfClosed) {
4865
4875
  return State.STYLE;
4866
4876
  } else {
4867
4877
  return State.TEXT;
4868
4878
  }
4879
+ case ContentModel.TEXTAREA:
4880
+ if (selfClosed) {
4881
+ return State.TEXTAREA;
4882
+ } else {
4883
+ return State.TEXT;
4884
+ }
4869
4885
  }
4870
4886
  }
4871
4887
  yield* this.match(
@@ -4930,6 +4946,16 @@ class Lexer {
4930
4946
  "expected </style>"
4931
4947
  );
4932
4948
  }
4949
+ *tokenizeTextarea(context) {
4950
+ yield* this.match(
4951
+ context,
4952
+ [
4953
+ [MATCH_TEXTAREA_END, State.TAG, TokenType.TAG_OPEN],
4954
+ [MATCH_TEXTAREA_DATA, State.TEXTAREA, TokenType.TEXT]
4955
+ ],
4956
+ "expected </textarea>"
4957
+ );
4958
+ }
4933
4959
  }
4934
4960
 
4935
4961
  const whitespace = /(\s+)/;
@@ -8151,6 +8177,9 @@ class NoRawCharacters extends Rule {
8151
8177
  setup() {
8152
8178
  this.on("element:ready", (event) => {
8153
8179
  const node = event.target;
8180
+ if (node.matches("script, style")) {
8181
+ return;
8182
+ }
8154
8183
  for (const child of node.childNodes) {
8155
8184
  if (child.nodeType !== NodeType.TEXT_NODE) {
8156
8185
  continue;
@@ -11803,7 +11832,7 @@ class EventHandler {
11803
11832
  }
11804
11833
 
11805
11834
  const name = "html-validate";
11806
- const version = "10.0.0";
11835
+ const version = "10.1.0";
11807
11836
  const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
11808
11837
 
11809
11838
  function freeze(src) {
@@ -12107,6 +12136,8 @@ class Parser {
12107
12136
  break;
12108
12137
  case TokenType.TEXT:
12109
12138
  case TokenType.TEMPLATING:
12139
+ case TokenType.SCRIPT:
12140
+ case TokenType.STYLE:
12110
12141
  this.appendText(token.data[0], token.location);
12111
12142
  break;
12112
12143
  case TokenType.EOF:
@@ -14200,7 +14231,7 @@ var ignoreExports = /*@__PURE__*/ requireIgnore();
14200
14231
  var ignore = /*@__PURE__*/getDefaultExportFromCjs(ignoreExports);
14201
14232
 
14202
14233
  const engines = {
14203
- node: ">= 20.6.0"
14234
+ node: "^20.19.0 || >= 22.12.0"
14204
14235
  };
14205
14236
 
14206
14237
  var workerPath = "./jest-worker.js";