vite 8.2.0 → 8.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.
@@ -1630,9 +1630,7 @@ var Tokenizer = class {
1630
1630
  case TokenType.NULL_CHARACTER:
1631
1631
  this.handler.onNullCharacter(this.currentCharacterToken);
1632
1632
  break;
1633
- case TokenType.WHITESPACE_CHARACTER:
1634
- this.handler.onWhitespaceCharacter(this.currentCharacterToken);
1635
- break;
1633
+ case TokenType.WHITESPACE_CHARACTER: this.handler.onWhitespaceCharacter(this.currentCharacterToken);
1636
1634
  }
1637
1635
  this.currentCharacterToken = null;
1638
1636
  }
@@ -1652,13 +1650,15 @@ var Tokenizer = class {
1652
1650
  this.active = false;
1653
1651
  }
1654
1652
  _appendCharToCurrentCharacterToken(type, ch) {
1655
- if (this.currentCharacterToken) if (this.currentCharacterToken.type === type) {
1656
- this.currentCharacterToken.chars += ch;
1657
- return;
1658
- } else {
1659
- this.currentLocation = this.getCurrentLocation(0);
1660
- this._emitCurrentCharacterToken(this.currentLocation);
1661
- this.preprocessor.dropParsedChunk();
1653
+ if (this.currentCharacterToken) {
1654
+ if (this.currentCharacterToken.type === type) {
1655
+ this.currentCharacterToken.chars += ch;
1656
+ return;
1657
+ } else {
1658
+ this.currentLocation = this.getCurrentLocation(0);
1659
+ this._emitCurrentCharacterToken(this.currentLocation);
1660
+ this.preprocessor.dropParsedChunk();
1661
+ }
1662
1662
  }
1663
1663
  this._createCharacterToken(type, ch);
1664
1664
  }
@@ -2634,14 +2634,15 @@ var Tokenizer = class {
2634
2634
  } else if (this._consumeSequenceIfMatch(SEQUENCES.DOCTYPE, false)) {
2635
2635
  this.currentLocation = this.getCurrentLocation(SEQUENCES.DOCTYPE.length + 1);
2636
2636
  this.state = State.DOCTYPE;
2637
- } else if (this._consumeSequenceIfMatch(SEQUENCES.CDATA_START, true)) if (this.inForeignNode) this.state = State.CDATA_SECTION;
2638
- else {
2639
- this._err(ERR.cdataInHtmlContent);
2640
- this._createCommentToken(SEQUENCES.CDATA_START.length + 1);
2641
- this.currentToken.data = "[CDATA[";
2642
- this.state = State.BOGUS_COMMENT;
2643
- }
2644
- else if (!this._ensureHibernation()) {
2637
+ } else if (this._consumeSequenceIfMatch(SEQUENCES.CDATA_START, true)) {
2638
+ if (this.inForeignNode) this.state = State.CDATA_SECTION;
2639
+ else {
2640
+ this._err(ERR.cdataInHtmlContent);
2641
+ this._createCommentToken(SEQUENCES.CDATA_START.length + 1);
2642
+ this.currentToken.data = "[CDATA[";
2643
+ this.state = State.BOGUS_COMMENT;
2644
+ }
2645
+ } else if (!this._ensureHibernation()) {
2645
2646
  this._err(ERR.incorrectlyOpenedComment);
2646
2647
  this._createCommentToken(2);
2647
2648
  this.state = State.BOGUS_COMMENT;
@@ -3272,8 +3273,6 @@ var Tokenizer = class {
3272
3273
  case CODE_POINTS.EOF:
3273
3274
  this.emitCurrentDoctype(token);
3274
3275
  this._emitEOFToken();
3275
- break;
3276
- default:
3277
3276
  }
3278
3277
  }
3279
3278
  _stateCdataSection(cp) {
@@ -3312,13 +3311,15 @@ var Tokenizer = class {
3312
3311
  }
3313
3312
  _stateCharacterReference() {
3314
3313
  let length = this.entityDecoder.write(this.preprocessor.html, this.preprocessor.pos);
3315
- if (length < 0) if (this.preprocessor.lastChunkWritten) length = this.entityDecoder.end();
3316
- else {
3317
- this.active = false;
3318
- this.preprocessor.pos = this.preprocessor.html.length - 1;
3319
- this.consumedAfterSnapshot = 0;
3320
- this.preprocessor.endOfChunkHit = true;
3321
- return;
3314
+ if (length < 0) {
3315
+ if (this.preprocessor.lastChunkWritten) length = this.entityDecoder.end();
3316
+ else {
3317
+ this.active = false;
3318
+ this.preprocessor.pos = this.preprocessor.html.length - 1;
3319
+ this.consumedAfterSnapshot = 0;
3320
+ this.preprocessor.endOfChunkHit = true;
3321
+ return;
3322
+ }
3322
3323
  }
3323
3324
  if (length === 0) {
3324
3325
  this.preprocessor.pos = this.entityStartPos;
@@ -3514,13 +3515,15 @@ var OpenElementStack = class {
3514
3515
  }
3515
3516
  remove(element) {
3516
3517
  const idx = this._indexOf(element);
3517
- if (idx >= 0) if (idx === this.stackTop) this.pop();
3518
- else {
3519
- this.items.splice(idx, 1);
3520
- this.tagIDs.splice(idx, 1);
3521
- this.stackTop--;
3522
- this._updateCurrentElement();
3523
- this.handler.onItemPop(element, false);
3518
+ if (idx >= 0) {
3519
+ if (idx === this.stackTop) this.pop();
3520
+ else {
3521
+ this.items.splice(idx, 1);
3522
+ this.tagIDs.splice(idx, 1);
3523
+ this.stackTop--;
3524
+ this._updateCurrentElement();
3525
+ this.handler.onItemPop(element, false);
3526
+ }
3524
3527
  }
3525
3528
  }
3526
3529
  tryPeekProperlyNestedBodyElement() {
@@ -3547,9 +3550,7 @@ var OpenElementStack = class {
3547
3550
  case NS.SVG:
3548
3551
  if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
3549
3552
  break;
3550
- case NS.MATHML:
3551
- if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
3552
- break;
3553
+ case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
3553
3554
  }
3554
3555
  }
3555
3556
  return true;
@@ -3574,9 +3575,7 @@ var OpenElementStack = class {
3574
3575
  case NS.SVG:
3575
3576
  if (SCOPING_ELEMENTS_SVG.has(tn)) return false;
3576
3577
  break;
3577
- case NS.MATHML:
3578
- if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
3579
- break;
3578
+ case NS.MATHML: if (SCOPING_ELEMENTS_MATHML.has(tn)) return false;
3580
3579
  }
3581
3580
  }
3582
3581
  return true;
@@ -4444,10 +4443,7 @@ var Parser = class {
4444
4443
  case TAG_ID.SCRIPT:
4445
4444
  this.tokenizer.state = TokenizerMode.SCRIPT_DATA;
4446
4445
  break;
4447
- case TAG_ID.PLAINTEXT:
4448
- this.tokenizer.state = TokenizerMode.PLAINTEXT;
4449
- break;
4450
- default:
4446
+ case TAG_ID.PLAINTEXT: this.tokenizer.state = TokenizerMode.PLAINTEXT;
4451
4447
  }
4452
4448
  }
4453
4449
  /** @protected */
@@ -4603,9 +4599,7 @@ var Parser = class {
4603
4599
  case TokenType.EOF:
4604
4600
  this.onEof(token);
4605
4601
  break;
4606
- case TokenType.WHITESPACE_CHARACTER:
4607
- this.onWhitespaceCharacter(token);
4608
- break;
4602
+ case TokenType.WHITESPACE_CHARACTER: this.onWhitespaceCharacter(token);
4609
4603
  }
4610
4604
  }
4611
4605
  /** @protected */
@@ -4679,12 +4673,10 @@ var Parser = class {
4679
4673
  return;
4680
4674
  }
4681
4675
  break;
4682
- case TAG_ID.HEAD:
4683
- if (i > 0) {
4684
- this.insertionMode = InsertionMode.IN_HEAD;
4685
- return;
4686
- }
4687
- break;
4676
+ case TAG_ID.HEAD: if (i > 0) {
4677
+ this.insertionMode = InsertionMode.IN_HEAD;
4678
+ return;
4679
+ }
4688
4680
  }
4689
4681
  this.insertionMode = InsertionMode.IN_BODY;
4690
4682
  }
@@ -4730,7 +4722,6 @@ var Parser = class {
4730
4722
  beforeElement: null
4731
4723
  };
4732
4724
  }
4733
- default:
4734
4725
  }
4735
4726
  }
4736
4727
  return {
@@ -4746,7 +4737,8 @@ var Parser = class {
4746
4737
  }
4747
4738
  /** @protected */
4748
4739
  _isSpecialElement(element, id) {
4749
- return SPECIAL_ELEMENTS[this.treeAdapter.getNamespaceURI(element)].has(id);
4740
+ const ns = this.treeAdapter.getNamespaceURI(element);
4741
+ return SPECIAL_ELEMENTS[ns].has(id);
4750
4742
  }
4751
4743
  /** @internal */
4752
4744
  onCharacter(token) {
@@ -4799,10 +4791,7 @@ var Parser = class {
4799
4791
  case InsertionMode.AFTER_BODY:
4800
4792
  tokenAfterBody(this, token);
4801
4793
  break;
4802
- case InsertionMode.AFTER_AFTER_BODY:
4803
- tokenAfterAfterBody(this, token);
4804
- break;
4805
- default:
4794
+ case InsertionMode.AFTER_AFTER_BODY: tokenAfterAfterBody(this, token);
4806
4795
  }
4807
4796
  }
4808
4797
  /** @internal */
@@ -4845,10 +4834,7 @@ var Parser = class {
4845
4834
  case InsertionMode.AFTER_BODY:
4846
4835
  tokenAfterBody(this, token);
4847
4836
  break;
4848
- case InsertionMode.AFTER_AFTER_BODY:
4849
- tokenAfterAfterBody(this, token);
4850
- break;
4851
- default:
4837
+ case InsertionMode.AFTER_AFTER_BODY: tokenAfterAfterBody(this, token);
4852
4838
  }
4853
4839
  }
4854
4840
  /** @internal */
@@ -4886,10 +4872,7 @@ var Parser = class {
4886
4872
  appendCommentToRootHtmlElement(this, token);
4887
4873
  break;
4888
4874
  case InsertionMode.AFTER_AFTER_BODY:
4889
- case InsertionMode.AFTER_AFTER_FRAMESET:
4890
- appendCommentToDocument(this, token);
4891
- break;
4892
- default:
4875
+ case InsertionMode.AFTER_AFTER_FRAMESET: appendCommentToDocument(this, token);
4893
4876
  }
4894
4877
  }
4895
4878
  /** @internal */
@@ -4905,10 +4888,7 @@ var Parser = class {
4905
4888
  case InsertionMode.AFTER_HEAD:
4906
4889
  this._err(token, ERR.misplacedDoctype);
4907
4890
  break;
4908
- case InsertionMode.IN_TABLE_TEXT:
4909
- tokenInTableText(this, token);
4910
- break;
4911
- default:
4891
+ case InsertionMode.IN_TABLE_TEXT: tokenInTableText(this, token);
4912
4892
  }
4913
4893
  }
4914
4894
  /** @internal */
@@ -4999,10 +4979,7 @@ var Parser = class {
4999
4979
  case InsertionMode.AFTER_AFTER_BODY:
5000
4980
  startTagAfterAfterBody(this, token);
5001
4981
  break;
5002
- case InsertionMode.AFTER_AFTER_FRAMESET:
5003
- startTagAfterAfterFrameset(this, token);
5004
- break;
5005
- default:
4982
+ case InsertionMode.AFTER_AFTER_FRAMESET: startTagAfterAfterFrameset(this, token);
5006
4983
  }
5007
4984
  }
5008
4985
  /** @internal */
@@ -5078,10 +5055,7 @@ var Parser = class {
5078
5055
  case InsertionMode.AFTER_FRAMESET:
5079
5056
  endTagAfterFrameset(this, token);
5080
5057
  break;
5081
- case InsertionMode.AFTER_AFTER_BODY:
5082
- tokenAfterAfterBody(this, token);
5083
- break;
5084
- default:
5058
+ case InsertionMode.AFTER_AFTER_BODY: tokenAfterAfterBody(this, token);
5085
5059
  }
5086
5060
  }
5087
5061
  /** @internal */
@@ -5129,10 +5103,7 @@ var Parser = class {
5129
5103
  case InsertionMode.IN_FRAMESET:
5130
5104
  case InsertionMode.AFTER_FRAMESET:
5131
5105
  case InsertionMode.AFTER_AFTER_BODY:
5132
- case InsertionMode.AFTER_AFTER_FRAMESET:
5133
- stopParsing(this, token);
5134
- break;
5135
- default:
5106
+ case InsertionMode.AFTER_AFTER_FRAMESET: stopParsing(this, token);
5136
5107
  }
5137
5108
  }
5138
5109
  /** @internal */
@@ -5174,10 +5145,7 @@ var Parser = class {
5174
5145
  case InsertionMode.IN_ROW:
5175
5146
  characterInTable(this, token);
5176
5147
  break;
5177
- case InsertionMode.IN_TABLE_TEXT:
5178
- whitespaceCharacterInTableText(this, token);
5179
- break;
5180
- default:
5148
+ case InsertionMode.IN_TABLE_TEXT: whitespaceCharacterInTableText(this, token);
5181
5149
  }
5182
5150
  }
5183
5151
  };
@@ -5529,10 +5497,7 @@ function modeInBody(p, token) {
5529
5497
  case TokenType.END_TAG:
5530
5498
  endTagInBody(p, token);
5531
5499
  break;
5532
- case TokenType.EOF:
5533
- eofInBody(p, token);
5534
- break;
5535
- default:
5500
+ case TokenType.EOF: eofInBody(p, token);
5536
5501
  }
5537
5502
  }
5538
5503
  function whitespaceCharacterInBody(p, token) {
@@ -6117,9 +6082,7 @@ function characterInTable(p, token) {
6117
6082
  case TokenType.CHARACTER:
6118
6083
  characterInTableText(p, token);
6119
6084
  break;
6120
- case TokenType.WHITESPACE_CHARACTER:
6121
- whitespaceCharacterInTableText(p, token);
6122
- break;
6085
+ case TokenType.WHITESPACE_CHARACTER: whitespaceCharacterInTableText(p, token);
6123
6086
  }
6124
6087
  } else tokenInTable(p, token);
6125
6088
  }
@@ -6531,10 +6494,7 @@ function startTagInSelect(p, token) {
6531
6494
  }
6532
6495
  break;
6533
6496
  case TAG_ID.SCRIPT:
6534
- case TAG_ID.TEMPLATE:
6535
- startTagInHead(p, token);
6536
- break;
6537
- default:
6497
+ case TAG_ID.TEMPLATE: startTagInHead(p, token);
6538
6498
  }
6539
6499
  }
6540
6500
  function endTagInSelect(p, token) {
@@ -6552,10 +6512,7 @@ function endTagInSelect(p, token) {
6552
6512
  p._resetInsertionMode();
6553
6513
  }
6554
6514
  break;
6555
- case TAG_ID.TEMPLATE:
6556
- templateEndTagInHead(p, token);
6557
- break;
6558
- default:
6515
+ case TAG_ID.TEMPLATE: templateEndTagInHead(p, token);
6559
6516
  }
6560
6517
  }
6561
6518
  function startTagInSelectInTable(p, token) {
@@ -6664,10 +6621,7 @@ function startTagInFrameset(p, token) {
6664
6621
  p._appendElement(token, NS.HTML);
6665
6622
  token.ackSelfClosing = true;
6666
6623
  break;
6667
- case TAG_ID.NOFRAMES:
6668
- startTagInHead(p, token);
6669
- break;
6670
- default:
6624
+ case TAG_ID.NOFRAMES: startTagInHead(p, token);
6671
6625
  }
6672
6626
  }
6673
6627
  function endTagInFrameset(p, token) {
@@ -6681,10 +6635,7 @@ function startTagAfterFrameset(p, token) {
6681
6635
  case TAG_ID.HTML:
6682
6636
  startTagInBody(p, token);
6683
6637
  break;
6684
- case TAG_ID.NOFRAMES:
6685
- startTagInHead(p, token);
6686
- break;
6687
- default:
6638
+ case TAG_ID.NOFRAMES: startTagInHead(p, token);
6688
6639
  }
6689
6640
  }
6690
6641
  function endTagAfterFrameset(p, token) {
@@ -6703,10 +6654,7 @@ function startTagAfterAfterFrameset(p, token) {
6703
6654
  case TAG_ID.HTML:
6704
6655
  startTagInBody(p, token);
6705
6656
  break;
6706
- case TAG_ID.NOFRAMES:
6707
- startTagInHead(p, token);
6708
- break;
6709
- default:
6657
+ case TAG_ID.NOFRAMES: startTagInHead(p, token);
6710
6658
  }
6711
6659
  }
6712
6660
  function nullCharacterInForeignContent(p, token) {