htmljs-parser 5.2.3 → 5.3.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/index.js +28 -26
- package/dist/index.mjs +28 -26
- package/dist/states/OPEN_TAG.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -420,7 +420,7 @@ var OPEN_TAG = {
|
|
|
420
420
|
hasArgs: false,
|
|
421
421
|
hasAttrs: false,
|
|
422
422
|
hasParams: false,
|
|
423
|
-
|
|
423
|
+
typeParams: void 0,
|
|
424
424
|
selfClosed: false,
|
|
425
425
|
shorthandEnd: -1,
|
|
426
426
|
tagName: void 0,
|
|
@@ -668,7 +668,7 @@ var OPEN_TAG = {
|
|
|
668
668
|
}
|
|
669
669
|
},
|
|
670
670
|
return(child, tag) {
|
|
671
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
671
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
672
672
|
if (child.state !== states_exports.EXPRESSION)
|
|
673
673
|
return;
|
|
674
674
|
switch (tag.stage) {
|
|
@@ -691,7 +691,7 @@ var OPEN_TAG = {
|
|
|
691
691
|
break;
|
|
692
692
|
}
|
|
693
693
|
case 2 /* ARGUMENT */: {
|
|
694
|
-
const {
|
|
694
|
+
const { typeParams } = tag;
|
|
695
695
|
const start = child.start - 1;
|
|
696
696
|
const end = ++this.pos;
|
|
697
697
|
const value = {
|
|
@@ -700,9 +700,9 @@ var OPEN_TAG = {
|
|
|
700
700
|
};
|
|
701
701
|
if (this.consumeWhitespaceIfBefore("{")) {
|
|
702
702
|
const attr = this.enterState(states_exports.ATTRIBUTE);
|
|
703
|
-
if (
|
|
704
|
-
attr.start =
|
|
705
|
-
attr.typeParams =
|
|
703
|
+
if (typeParams) {
|
|
704
|
+
attr.start = typeParams.start;
|
|
705
|
+
attr.typeParams = typeParams;
|
|
706
706
|
} else {
|
|
707
707
|
attr.start = start;
|
|
708
708
|
}
|
|
@@ -710,10 +710,15 @@ var OPEN_TAG = {
|
|
|
710
710
|
this.forward = 0;
|
|
711
711
|
tag.hasAttrs = true;
|
|
712
712
|
} else {
|
|
713
|
-
if (
|
|
714
|
-
|
|
713
|
+
if (typeParams) {
|
|
714
|
+
this.emitError(
|
|
715
|
+
child,
|
|
716
|
+
27 /* INVALID_TAG_TYPES */,
|
|
717
|
+
"Unexpected types. Type arguments must directly follow a tag name and type paremeters must precede a method or tag parameters."
|
|
718
|
+
);
|
|
719
|
+
break;
|
|
715
720
|
}
|
|
716
|
-
(
|
|
721
|
+
(_d = (_c = this.options).onTagArgs) == null ? void 0 : _d.call(_c, {
|
|
717
722
|
start,
|
|
718
723
|
end,
|
|
719
724
|
value
|
|
@@ -722,9 +727,9 @@ var OPEN_TAG = {
|
|
|
722
727
|
break;
|
|
723
728
|
}
|
|
724
729
|
case 3 /* TYPES */: {
|
|
725
|
-
const {
|
|
730
|
+
const { typeParams, hasParams, hasArgs } = tag;
|
|
726
731
|
const end = ++this.pos;
|
|
727
|
-
const
|
|
732
|
+
const types = {
|
|
728
733
|
start: child.start - 1,
|
|
729
734
|
end,
|
|
730
735
|
value: {
|
|
@@ -732,33 +737,28 @@ var OPEN_TAG = {
|
|
|
732
737
|
end: child.end
|
|
733
738
|
}
|
|
734
739
|
};
|
|
740
|
+
if (tag.tagName.end === types.start) {
|
|
741
|
+
(_f = (_e = this.options).onTagTypeArgs) == null ? void 0 : _f.call(_e, types);
|
|
742
|
+
break;
|
|
743
|
+
}
|
|
735
744
|
this.consumeWhitespace();
|
|
736
745
|
const nextCode = this.lookAtCharCodeAhead(0);
|
|
737
|
-
if (
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
(_j = (_i = this.options).onTagTypeParams) == null ? void 0 : _j.call(_i, typeArgs);
|
|
742
|
-
} else if (!hasArgs && nextCode === 40 /* OPEN_PAREN */) {
|
|
743
|
-
if (types) {
|
|
744
|
-
(_l = (_k = this.options).onTagTypeArgs) == null ? void 0 : _l.call(_k, types);
|
|
745
|
-
}
|
|
746
|
-
tag.types = typeArgs;
|
|
747
|
-
} else if (!(types || hasParams || hasArgs)) {
|
|
748
|
-
(_n = (_m = this.options).onTagTypeArgs) == null ? void 0 : _n.call(_m, typeArgs);
|
|
749
|
-
tag.types = typeArgs;
|
|
746
|
+
if (nextCode === 124 /* PIPE */ && !hasParams) {
|
|
747
|
+
(_h = (_g = this.options).onTagTypeParams) == null ? void 0 : _h.call(_g, types);
|
|
748
|
+
} else if (nextCode === 40 /* OPEN_PAREN */ && !(typeParams || hasParams || hasArgs)) {
|
|
749
|
+
tag.typeParams = types;
|
|
750
750
|
} else {
|
|
751
751
|
this.emitError(
|
|
752
752
|
child,
|
|
753
753
|
27 /* INVALID_TAG_TYPES */,
|
|
754
|
-
"Unexpected types. Type arguments must follow a tag name and type paremeters must precede a method or tag parameters."
|
|
754
|
+
"Unexpected types. Type arguments must directly follow a tag name and type paremeters must precede a method or tag parameters."
|
|
755
755
|
);
|
|
756
756
|
}
|
|
757
757
|
break;
|
|
758
758
|
}
|
|
759
759
|
case 4 /* PARAMS */: {
|
|
760
760
|
const end = ++this.pos;
|
|
761
|
-
(
|
|
761
|
+
(_j = (_i = this.options).onTagParams) == null ? void 0 : _j.call(_i, {
|
|
762
762
|
start: child.start - 1,
|
|
763
763
|
end,
|
|
764
764
|
value: {
|
|
@@ -780,6 +780,8 @@ function shouldTerminateConciseTagVar(code, data, pos) {
|
|
|
780
780
|
case 59 /* SEMICOLON */:
|
|
781
781
|
case 60 /* OPEN_ANGLE_BRACKET */:
|
|
782
782
|
return true;
|
|
783
|
+
case 45 /* HYPHEN */:
|
|
784
|
+
return data.charCodeAt(pos + 1) === 45 /* HYPHEN */;
|
|
783
785
|
case 58 /* COLON */:
|
|
784
786
|
return data.charCodeAt(pos + 1) === 61 /* EQUAL */;
|
|
785
787
|
default:
|
package/dist/index.mjs
CHANGED
|
@@ -395,7 +395,7 @@ var OPEN_TAG = {
|
|
|
395
395
|
hasArgs: false,
|
|
396
396
|
hasAttrs: false,
|
|
397
397
|
hasParams: false,
|
|
398
|
-
|
|
398
|
+
typeParams: void 0,
|
|
399
399
|
selfClosed: false,
|
|
400
400
|
shorthandEnd: -1,
|
|
401
401
|
tagName: void 0,
|
|
@@ -643,7 +643,7 @@ var OPEN_TAG = {
|
|
|
643
643
|
}
|
|
644
644
|
},
|
|
645
645
|
return(child, tag) {
|
|
646
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j
|
|
646
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
647
647
|
if (child.state !== states_exports.EXPRESSION)
|
|
648
648
|
return;
|
|
649
649
|
switch (tag.stage) {
|
|
@@ -666,7 +666,7 @@ var OPEN_TAG = {
|
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
668
|
case 2 /* ARGUMENT */: {
|
|
669
|
-
const {
|
|
669
|
+
const { typeParams } = tag;
|
|
670
670
|
const start = child.start - 1;
|
|
671
671
|
const end = ++this.pos;
|
|
672
672
|
const value = {
|
|
@@ -675,9 +675,9 @@ var OPEN_TAG = {
|
|
|
675
675
|
};
|
|
676
676
|
if (this.consumeWhitespaceIfBefore("{")) {
|
|
677
677
|
const attr = this.enterState(states_exports.ATTRIBUTE);
|
|
678
|
-
if (
|
|
679
|
-
attr.start =
|
|
680
|
-
attr.typeParams =
|
|
678
|
+
if (typeParams) {
|
|
679
|
+
attr.start = typeParams.start;
|
|
680
|
+
attr.typeParams = typeParams;
|
|
681
681
|
} else {
|
|
682
682
|
attr.start = start;
|
|
683
683
|
}
|
|
@@ -685,10 +685,15 @@ var OPEN_TAG = {
|
|
|
685
685
|
this.forward = 0;
|
|
686
686
|
tag.hasAttrs = true;
|
|
687
687
|
} else {
|
|
688
|
-
if (
|
|
689
|
-
|
|
688
|
+
if (typeParams) {
|
|
689
|
+
this.emitError(
|
|
690
|
+
child,
|
|
691
|
+
27 /* INVALID_TAG_TYPES */,
|
|
692
|
+
"Unexpected types. Type arguments must directly follow a tag name and type paremeters must precede a method or tag parameters."
|
|
693
|
+
);
|
|
694
|
+
break;
|
|
690
695
|
}
|
|
691
|
-
(
|
|
696
|
+
(_d = (_c = this.options).onTagArgs) == null ? void 0 : _d.call(_c, {
|
|
692
697
|
start,
|
|
693
698
|
end,
|
|
694
699
|
value
|
|
@@ -697,9 +702,9 @@ var OPEN_TAG = {
|
|
|
697
702
|
break;
|
|
698
703
|
}
|
|
699
704
|
case 3 /* TYPES */: {
|
|
700
|
-
const {
|
|
705
|
+
const { typeParams, hasParams, hasArgs } = tag;
|
|
701
706
|
const end = ++this.pos;
|
|
702
|
-
const
|
|
707
|
+
const types = {
|
|
703
708
|
start: child.start - 1,
|
|
704
709
|
end,
|
|
705
710
|
value: {
|
|
@@ -707,33 +712,28 @@ var OPEN_TAG = {
|
|
|
707
712
|
end: child.end
|
|
708
713
|
}
|
|
709
714
|
};
|
|
715
|
+
if (tag.tagName.end === types.start) {
|
|
716
|
+
(_f = (_e = this.options).onTagTypeArgs) == null ? void 0 : _f.call(_e, types);
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
710
719
|
this.consumeWhitespace();
|
|
711
720
|
const nextCode = this.lookAtCharCodeAhead(0);
|
|
712
|
-
if (
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
(_j = (_i = this.options).onTagTypeParams) == null ? void 0 : _j.call(_i, typeArgs);
|
|
717
|
-
} else if (!hasArgs && nextCode === 40 /* OPEN_PAREN */) {
|
|
718
|
-
if (types) {
|
|
719
|
-
(_l = (_k = this.options).onTagTypeArgs) == null ? void 0 : _l.call(_k, types);
|
|
720
|
-
}
|
|
721
|
-
tag.types = typeArgs;
|
|
722
|
-
} else if (!(types || hasParams || hasArgs)) {
|
|
723
|
-
(_n = (_m = this.options).onTagTypeArgs) == null ? void 0 : _n.call(_m, typeArgs);
|
|
724
|
-
tag.types = typeArgs;
|
|
721
|
+
if (nextCode === 124 /* PIPE */ && !hasParams) {
|
|
722
|
+
(_h = (_g = this.options).onTagTypeParams) == null ? void 0 : _h.call(_g, types);
|
|
723
|
+
} else if (nextCode === 40 /* OPEN_PAREN */ && !(typeParams || hasParams || hasArgs)) {
|
|
724
|
+
tag.typeParams = types;
|
|
725
725
|
} else {
|
|
726
726
|
this.emitError(
|
|
727
727
|
child,
|
|
728
728
|
27 /* INVALID_TAG_TYPES */,
|
|
729
|
-
"Unexpected types. Type arguments must follow a tag name and type paremeters must precede a method or tag parameters."
|
|
729
|
+
"Unexpected types. Type arguments must directly follow a tag name and type paremeters must precede a method or tag parameters."
|
|
730
730
|
);
|
|
731
731
|
}
|
|
732
732
|
break;
|
|
733
733
|
}
|
|
734
734
|
case 4 /* PARAMS */: {
|
|
735
735
|
const end = ++this.pos;
|
|
736
|
-
(
|
|
736
|
+
(_j = (_i = this.options).onTagParams) == null ? void 0 : _j.call(_i, {
|
|
737
737
|
start: child.start - 1,
|
|
738
738
|
end,
|
|
739
739
|
value: {
|
|
@@ -755,6 +755,8 @@ function shouldTerminateConciseTagVar(code, data, pos) {
|
|
|
755
755
|
case 59 /* SEMICOLON */:
|
|
756
756
|
case 60 /* OPEN_ANGLE_BRACKET */:
|
|
757
757
|
return true;
|
|
758
|
+
case 45 /* HYPHEN */:
|
|
759
|
+
return data.charCodeAt(pos + 1) === 45 /* HYPHEN */;
|
|
758
760
|
case 58 /* COLON */:
|
|
759
761
|
return data.charCodeAt(pos + 1) === 61 /* EQUAL */;
|
|
760
762
|
default:
|
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.
|
|
4
|
+
"version": "5.3.0",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@changesets/changelog-github": "^0.4.7",
|
|
7
7
|
"@changesets/cli": "^2.25.2",
|