htmljs-parser 5.7.1 → 5.7.3

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/index.js CHANGED
@@ -673,11 +673,15 @@ var OPEN_TAG = {
673
673
  this.pos++;
674
674
  this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesPipe;
675
675
  break;
676
- case 60 /* OPEN_ANGLE_BRACKET */:
676
+ case 60 /* OPEN_ANGLE_BRACKET */: {
677
677
  tag.stage = 3 /* TYPES */;
678
678
  this.pos++;
679
- this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseAngleBracket;
679
+ const expr = this.enterState(states_exports.EXPRESSION);
680
+ expr.inType = true;
681
+ expr.forceType = true;
682
+ expr.shouldTerminate = matchesCloseAngleBracket;
680
683
  break;
684
+ }
681
685
  default:
682
686
  tag.hasAttrs = true;
683
687
  this.enterState(states_exports.ATTRIBUTE);
@@ -885,7 +889,10 @@ var ATTRIBUTE = {
885
889
  attr.stage = 4 /* TYPE_PARAMS */;
886
890
  this.pos++;
887
891
  this.forward = 0;
888
- this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseAngleBracket;
892
+ const expr = this.enterState(states_exports.EXPRESSION);
893
+ expr.inType = true;
894
+ expr.forceType = true;
895
+ expr.shouldTerminate = matchesCloseAngleBracket;
889
896
  } else if (code === 123 /* OPEN_CURLY_BRACE */ && attr.args) {
890
897
  ensureAttrName(this, attr);
891
898
  attr.stage = 5 /* BLOCK */;
@@ -1620,19 +1627,22 @@ var DTD = {
1620
1627
  // src/states/EXPRESSION.ts
1621
1628
  var shouldTerminate = () => false;
1622
1629
  var unaryKeywords = [
1623
- "asserts",
1624
1630
  "async",
1625
1631
  "await",
1626
1632
  "class",
1627
1633
  "function",
1634
+ "new",
1635
+ "typeof",
1636
+ "void"
1637
+ ];
1638
+ var tsUnaryKeywords = [
1639
+ ...unaryKeywords,
1640
+ "asserts",
1628
1641
  "infer",
1629
1642
  "is",
1630
1643
  "keyof",
1631
- "new",
1632
1644
  "readonly",
1633
- "typeof",
1634
- "unique",
1635
- "void"
1645
+ "unique"
1636
1646
  ];
1637
1647
  var binaryKeywords = [
1638
1648
  "as",
@@ -1727,6 +1737,9 @@ var EXPRESSION = {
1727
1737
  case 61 /* EQUAL */:
1728
1738
  if (expression.operators) {
1729
1739
  if (this.lookAtCharCodeAhead(1) === 62 /* CLOSE_ANGLE_BRACKET */) {
1740
+ if (expression.inType && !expression.forceType && this.getPreviousNonWhitespaceCharCode() !== 41 /* CLOSE_PAREN */) {
1741
+ expression.inType = false;
1742
+ }
1730
1743
  this.pos++;
1731
1744
  } else if (!(expression.forceType || expression.groupStack.length)) {
1732
1745
  expression.inType = false;
@@ -1918,7 +1931,7 @@ function lookBehindForOperator(expression, data, pos) {
1918
1931
  return curPos;
1919
1932
  }
1920
1933
  default: {
1921
- for (const keyword of unaryKeywords) {
1934
+ for (const keyword of expression.inType ? tsUnaryKeywords : unaryKeywords) {
1922
1935
  const keywordPos = lookBehindFor(data, curPos, keyword);
1923
1936
  if (keywordPos !== -1) {
1924
1937
  return isWordOrPeriodCode(data.charCodeAt(keywordPos - 1)) ? -1 : keywordPos;
package/dist/index.mjs CHANGED
@@ -648,11 +648,15 @@ var OPEN_TAG = {
648
648
  this.pos++;
649
649
  this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesPipe;
650
650
  break;
651
- case 60 /* OPEN_ANGLE_BRACKET */:
651
+ case 60 /* OPEN_ANGLE_BRACKET */: {
652
652
  tag.stage = 3 /* TYPES */;
653
653
  this.pos++;
654
- this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseAngleBracket;
654
+ const expr = this.enterState(states_exports.EXPRESSION);
655
+ expr.inType = true;
656
+ expr.forceType = true;
657
+ expr.shouldTerminate = matchesCloseAngleBracket;
655
658
  break;
659
+ }
656
660
  default:
657
661
  tag.hasAttrs = true;
658
662
  this.enterState(states_exports.ATTRIBUTE);
@@ -860,7 +864,10 @@ var ATTRIBUTE = {
860
864
  attr.stage = 4 /* TYPE_PARAMS */;
861
865
  this.pos++;
862
866
  this.forward = 0;
863
- this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseAngleBracket;
867
+ const expr = this.enterState(states_exports.EXPRESSION);
868
+ expr.inType = true;
869
+ expr.forceType = true;
870
+ expr.shouldTerminate = matchesCloseAngleBracket;
864
871
  } else if (code === 123 /* OPEN_CURLY_BRACE */ && attr.args) {
865
872
  ensureAttrName(this, attr);
866
873
  attr.stage = 5 /* BLOCK */;
@@ -1595,19 +1602,22 @@ var DTD = {
1595
1602
  // src/states/EXPRESSION.ts
1596
1603
  var shouldTerminate = () => false;
1597
1604
  var unaryKeywords = [
1598
- "asserts",
1599
1605
  "async",
1600
1606
  "await",
1601
1607
  "class",
1602
1608
  "function",
1609
+ "new",
1610
+ "typeof",
1611
+ "void"
1612
+ ];
1613
+ var tsUnaryKeywords = [
1614
+ ...unaryKeywords,
1615
+ "asserts",
1603
1616
  "infer",
1604
1617
  "is",
1605
1618
  "keyof",
1606
- "new",
1607
1619
  "readonly",
1608
- "typeof",
1609
- "unique",
1610
- "void"
1620
+ "unique"
1611
1621
  ];
1612
1622
  var binaryKeywords = [
1613
1623
  "as",
@@ -1702,6 +1712,9 @@ var EXPRESSION = {
1702
1712
  case 61 /* EQUAL */:
1703
1713
  if (expression.operators) {
1704
1714
  if (this.lookAtCharCodeAhead(1) === 62 /* CLOSE_ANGLE_BRACKET */) {
1715
+ if (expression.inType && !expression.forceType && this.getPreviousNonWhitespaceCharCode() !== 41 /* CLOSE_PAREN */) {
1716
+ expression.inType = false;
1717
+ }
1705
1718
  this.pos++;
1706
1719
  } else if (!(expression.forceType || expression.groupStack.length)) {
1707
1720
  expression.inType = false;
@@ -1893,7 +1906,7 @@ function lookBehindForOperator(expression, data, pos) {
1893
1906
  return curPos;
1894
1907
  }
1895
1908
  default: {
1896
- for (const keyword of unaryKeywords) {
1909
+ for (const keyword of expression.inType ? tsUnaryKeywords : unaryKeywords) {
1897
1910
  const keywordPos = lookBehindFor(data, curPos, keyword);
1898
1911
  if (keywordPos !== -1) {
1899
1912
  return isWordOrPeriodCode(data.charCodeAt(keywordPos - 1)) ? -1 : keywordPos;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "htmljs-parser",
3
3
  "description": "An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values",
4
- "version": "5.7.1",
4
+ "version": "5.7.3",
5
5
  "devDependencies": {
6
6
  "@changesets/changelog-github": "^0.5.0",
7
7
  "@changesets/cli": "^2.27.1",