htmljs-parser 5.7.1 → 5.7.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.
- package/dist/index.js +19 -9
- package/dist/index.mjs +19 -9
- package/package.json +1 -1
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)
|
|
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)
|
|
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
|
-
"
|
|
1634
|
-
"unique",
|
|
1635
|
-
"void"
|
|
1645
|
+
"unique"
|
|
1636
1646
|
];
|
|
1637
1647
|
var binaryKeywords = [
|
|
1638
1648
|
"as",
|
|
@@ -1918,7 +1928,7 @@ function lookBehindForOperator(expression, data, pos) {
|
|
|
1918
1928
|
return curPos;
|
|
1919
1929
|
}
|
|
1920
1930
|
default: {
|
|
1921
|
-
for (const keyword of unaryKeywords) {
|
|
1931
|
+
for (const keyword of expression.inType ? tsUnaryKeywords : unaryKeywords) {
|
|
1922
1932
|
const keywordPos = lookBehindFor(data, curPos, keyword);
|
|
1923
1933
|
if (keywordPos !== -1) {
|
|
1924
1934
|
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)
|
|
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)
|
|
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
|
-
"
|
|
1609
|
-
"unique",
|
|
1610
|
-
"void"
|
|
1620
|
+
"unique"
|
|
1611
1621
|
];
|
|
1612
1622
|
var binaryKeywords = [
|
|
1613
1623
|
"as",
|
|
@@ -1893,7 +1903,7 @@ function lookBehindForOperator(expression, data, pos) {
|
|
|
1893
1903
|
return curPos;
|
|
1894
1904
|
}
|
|
1895
1905
|
default: {
|
|
1896
|
-
for (const keyword of unaryKeywords) {
|
|
1906
|
+
for (const keyword of expression.inType ? tsUnaryKeywords : unaryKeywords) {
|
|
1897
1907
|
const keywordPos = lookBehindFor(data, curPos, keyword);
|
|
1898
1908
|
if (keywordPos !== -1) {
|
|
1899
1909
|
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.
|
|
4
|
+
"version": "5.7.2",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@changesets/changelog-github": "^0.5.0",
|
|
7
7
|
"@changesets/cli": "^2.27.1",
|