@vue/compiler-dom 3.3.0-alpha.2 → 3.3.0-alpha.4
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/compiler-dom.cjs.js +12 -12
- package/dist/compiler-dom.cjs.prod.js +9 -9
- package/dist/compiler-dom.esm-browser.js +60 -60
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +5 -5
- package/dist/compiler-dom.global.js +60 -60
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
package/dist/compiler-dom.cjs.js
CHANGED
|
@@ -2429,7 +2429,7 @@ const parserOptions = {
|
|
|
2429
2429
|
};
|
|
2430
2430
|
|
|
2431
2431
|
const transformStyle = (node) => {
|
|
2432
|
-
if (node.type ===
|
|
2432
|
+
if (node.type === 1) {
|
|
2433
2433
|
node.props.forEach((p, i) => {
|
|
2434
2434
|
if (p.type === 6 && p.name === "style" && p.value) {
|
|
2435
2435
|
node.props[i] = {
|
|
@@ -2719,7 +2719,7 @@ const transformShow = (dir, node, context) => {
|
|
|
2719
2719
|
};
|
|
2720
2720
|
|
|
2721
2721
|
const transformTransition = (node, context) => {
|
|
2722
|
-
if (node.type ===
|
|
2722
|
+
if (node.type === 1 && node.tagType === 1) {
|
|
2723
2723
|
const component = context.isBuiltInComponent(node.tag);
|
|
2724
2724
|
if (component === TRANSITION) {
|
|
2725
2725
|
return () => {
|
|
@@ -2739,7 +2739,7 @@ const transformTransition = (node, context) => {
|
|
|
2739
2739
|
);
|
|
2740
2740
|
}
|
|
2741
2741
|
const child = node.children[0];
|
|
2742
|
-
if (child.type ===
|
|
2742
|
+
if (child.type === 1) {
|
|
2743
2743
|
for (const p of child.props) {
|
|
2744
2744
|
if (p.type === 7 && p.name === "show") {
|
|
2745
2745
|
node.props.push({
|
|
@@ -2757,7 +2757,7 @@ const transformTransition = (node, context) => {
|
|
|
2757
2757
|
};
|
|
2758
2758
|
function hasMultipleChildren(node) {
|
|
2759
2759
|
const children = node.children = node.children.filter(
|
|
2760
|
-
(c) => c.type !==
|
|
2760
|
+
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
|
2761
2761
|
);
|
|
2762
2762
|
const child = children[0];
|
|
2763
2763
|
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
|
@@ -2814,7 +2814,7 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2814
2814
|
}
|
|
2815
2815
|
stringifyCurrentChunk(i);
|
|
2816
2816
|
};
|
|
2817
|
-
const getHoistedNode = (node) => (node.type ===
|
|
2817
|
+
const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
|
|
2818
2818
|
const dataAriaRE = /^(data|aria)-/;
|
|
2819
2819
|
const isStringifiableAttr = (name, ns) => {
|
|
2820
2820
|
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
|
|
@@ -2827,7 +2827,7 @@ const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
|
|
|
2827
2827
|
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
|
|
2828
2828
|
);
|
|
2829
2829
|
function analyzeNode(node) {
|
|
2830
|
-
if (node.type ===
|
|
2830
|
+
if (node.type === 1 && isNonStringifiable(node.tag)) {
|
|
2831
2831
|
return false;
|
|
2832
2832
|
}
|
|
2833
2833
|
if (node.type === 12) {
|
|
@@ -2858,7 +2858,7 @@ function analyzeNode(node) {
|
|
|
2858
2858
|
for (let i = 0; i < node2.children.length; i++) {
|
|
2859
2859
|
nc++;
|
|
2860
2860
|
const child = node2.children[i];
|
|
2861
|
-
if (child.type ===
|
|
2861
|
+
if (child.type === 1) {
|
|
2862
2862
|
if (child.props.length > 0) {
|
|
2863
2863
|
ec++;
|
|
2864
2864
|
}
|
|
@@ -2880,11 +2880,11 @@ function stringifyNode(node, context) {
|
|
|
2880
2880
|
return ``;
|
|
2881
2881
|
}
|
|
2882
2882
|
switch (node.type) {
|
|
2883
|
-
case
|
|
2883
|
+
case 1:
|
|
2884
2884
|
return stringifyElement(node, context);
|
|
2885
|
-
case
|
|
2885
|
+
case 2:
|
|
2886
2886
|
return shared.escapeHtml(node.content);
|
|
2887
|
-
case
|
|
2887
|
+
case 3:
|
|
2888
2888
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
2889
2889
|
case 5:
|
|
2890
2890
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
@@ -2962,7 +2962,7 @@ function evaluateConstant(exp) {
|
|
|
2962
2962
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
|
2963
2963
|
return;
|
|
2964
2964
|
}
|
|
2965
|
-
if (c.type ===
|
|
2965
|
+
if (c.type === 2) {
|
|
2966
2966
|
res += c.content;
|
|
2967
2967
|
} else if (c.type === 5) {
|
|
2968
2968
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
@@ -2975,7 +2975,7 @@ function evaluateConstant(exp) {
|
|
|
2975
2975
|
}
|
|
2976
2976
|
|
|
2977
2977
|
const ignoreSideEffectTags = (node, context) => {
|
|
2978
|
-
if (node.type ===
|
|
2978
|
+
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
|
2979
2979
|
context.onError(
|
|
2980
2980
|
createDOMCompilerError(61, node.loc)
|
|
2981
2981
|
);
|
|
@@ -2429,7 +2429,7 @@ const parserOptions = {
|
|
|
2429
2429
|
};
|
|
2430
2430
|
|
|
2431
2431
|
const transformStyle = (node) => {
|
|
2432
|
-
if (node.type ===
|
|
2432
|
+
if (node.type === 1) {
|
|
2433
2433
|
node.props.forEach((p, i) => {
|
|
2434
2434
|
if (p.type === 6 && p.name === "style" && p.value) {
|
|
2435
2435
|
node.props[i] = {
|
|
@@ -2751,7 +2751,7 @@ const stringifyStatic = (children, context, parent) => {
|
|
|
2751
2751
|
}
|
|
2752
2752
|
stringifyCurrentChunk(i);
|
|
2753
2753
|
};
|
|
2754
|
-
const getHoistedNode = (node) => (node.type ===
|
|
2754
|
+
const getHoistedNode = (node) => (node.type === 1 && node.tagType === 0 || node.type == 12) && node.codegenNode && node.codegenNode.type === 4 && node.codegenNode.hoisted;
|
|
2755
2755
|
const dataAriaRE = /^(data|aria)-/;
|
|
2756
2756
|
const isStringifiableAttr = (name, ns) => {
|
|
2757
2757
|
return (ns === 0 ? shared.isKnownHtmlAttr(name) : ns === 1 ? shared.isKnownSvgAttr(name) : false) || dataAriaRE.test(name);
|
|
@@ -2764,7 +2764,7 @@ const isNonStringifiable = /* @__PURE__ */ shared.makeMap(
|
|
|
2764
2764
|
`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
|
|
2765
2765
|
);
|
|
2766
2766
|
function analyzeNode(node) {
|
|
2767
|
-
if (node.type ===
|
|
2767
|
+
if (node.type === 1 && isNonStringifiable(node.tag)) {
|
|
2768
2768
|
return false;
|
|
2769
2769
|
}
|
|
2770
2770
|
if (node.type === 12) {
|
|
@@ -2795,7 +2795,7 @@ function analyzeNode(node) {
|
|
|
2795
2795
|
for (let i = 0; i < node2.children.length; i++) {
|
|
2796
2796
|
nc++;
|
|
2797
2797
|
const child = node2.children[i];
|
|
2798
|
-
if (child.type ===
|
|
2798
|
+
if (child.type === 1) {
|
|
2799
2799
|
if (child.props.length > 0) {
|
|
2800
2800
|
ec++;
|
|
2801
2801
|
}
|
|
@@ -2817,11 +2817,11 @@ function stringifyNode(node, context) {
|
|
|
2817
2817
|
return ``;
|
|
2818
2818
|
}
|
|
2819
2819
|
switch (node.type) {
|
|
2820
|
-
case
|
|
2820
|
+
case 1:
|
|
2821
2821
|
return stringifyElement(node, context);
|
|
2822
|
-
case
|
|
2822
|
+
case 2:
|
|
2823
2823
|
return shared.escapeHtml(node.content);
|
|
2824
|
-
case
|
|
2824
|
+
case 3:
|
|
2825
2825
|
return `<!--${shared.escapeHtml(node.content)}-->`;
|
|
2826
2826
|
case 5:
|
|
2827
2827
|
return shared.escapeHtml(shared.toDisplayString(evaluateConstant(node.content)));
|
|
@@ -2899,7 +2899,7 @@ function evaluateConstant(exp) {
|
|
|
2899
2899
|
if (shared.isString(c) || shared.isSymbol(c)) {
|
|
2900
2900
|
return;
|
|
2901
2901
|
}
|
|
2902
|
-
if (c.type ===
|
|
2902
|
+
if (c.type === 2) {
|
|
2903
2903
|
res += c.content;
|
|
2904
2904
|
} else if (c.type === 5) {
|
|
2905
2905
|
res += shared.toDisplayString(evaluateConstant(c.content));
|
|
@@ -2912,7 +2912,7 @@ function evaluateConstant(exp) {
|
|
|
2912
2912
|
}
|
|
2913
2913
|
|
|
2914
2914
|
const ignoreSideEffectTags = (node, context) => {
|
|
2915
|
-
if (node.type ===
|
|
2915
|
+
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
|
2916
2916
|
context.onError(
|
|
2917
2917
|
createDOMCompilerError(61, node.loc)
|
|
2918
2918
|
);
|
|
@@ -625,16 +625,16 @@ function hasDynamicKeyVBind(node) {
|
|
|
625
625
|
);
|
|
626
626
|
}
|
|
627
627
|
function isText$1(node) {
|
|
628
|
-
return node.type === 5 || node.type ===
|
|
628
|
+
return node.type === 5 || node.type === 2;
|
|
629
629
|
}
|
|
630
630
|
function isVSlot(p) {
|
|
631
631
|
return p.type === 7 && p.name === "slot";
|
|
632
632
|
}
|
|
633
633
|
function isTemplateNode(node) {
|
|
634
|
-
return node.type ===
|
|
634
|
+
return node.type === 1 && node.tagType === 3;
|
|
635
635
|
}
|
|
636
636
|
function isSlotOutlet(node) {
|
|
637
|
-
return node.type ===
|
|
637
|
+
return node.type === 1 && node.tagType === 2;
|
|
638
638
|
}
|
|
639
639
|
function getVNodeHelper(ssr, isComponent) {
|
|
640
640
|
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
@@ -733,7 +733,7 @@ function hasScopeRef(node, ids) {
|
|
|
733
733
|
return false;
|
|
734
734
|
}
|
|
735
735
|
switch (node.type) {
|
|
736
|
-
case
|
|
736
|
+
case 1:
|
|
737
737
|
for (let i = 0; i < node.props.length; i++) {
|
|
738
738
|
const p = node.props[i];
|
|
739
739
|
if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
@@ -760,8 +760,8 @@ function hasScopeRef(node, ids) {
|
|
|
760
760
|
case 5:
|
|
761
761
|
case 12:
|
|
762
762
|
return hasScopeRef(node.content, ids);
|
|
763
|
-
case
|
|
764
|
-
case
|
|
763
|
+
case 2:
|
|
764
|
+
case 3:
|
|
765
765
|
return false;
|
|
766
766
|
default:
|
|
767
767
|
return false;
|
|
@@ -992,12 +992,12 @@ function parseChildren(context, mode, ancestors) {
|
|
|
992
992
|
const shouldCondense = context.options.whitespace !== "preserve";
|
|
993
993
|
for (let i = 0; i < nodes.length; i++) {
|
|
994
994
|
const node = nodes[i];
|
|
995
|
-
if (node.type ===
|
|
995
|
+
if (node.type === 2) {
|
|
996
996
|
if (!context.inPre) {
|
|
997
997
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
998
998
|
const prev = nodes[i - 1];
|
|
999
999
|
const next = nodes[i + 1];
|
|
1000
|
-
if (!prev || !next || shouldCondense && (prev.type ===
|
|
1000
|
+
if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
|
|
1001
1001
|
removedWhitespace = true;
|
|
1002
1002
|
nodes[i] = null;
|
|
1003
1003
|
} else {
|
|
@@ -1009,14 +1009,14 @@ function parseChildren(context, mode, ancestors) {
|
|
|
1009
1009
|
} else {
|
|
1010
1010
|
node.content = node.content.replace(/\r\n/g, "\n");
|
|
1011
1011
|
}
|
|
1012
|
-
} else if (node.type ===
|
|
1012
|
+
} else if (node.type === 3 && !context.options.comments) {
|
|
1013
1013
|
removedWhitespace = true;
|
|
1014
1014
|
nodes[i] = null;
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
1017
|
if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
|
1018
1018
|
const first = nodes[0];
|
|
1019
|
-
if (first && first.type ===
|
|
1019
|
+
if (first && first.type === 2) {
|
|
1020
1020
|
first.content = first.content.replace(/^\r?\n/, "");
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
@@ -1024,9 +1024,9 @@ function parseChildren(context, mode, ancestors) {
|
|
|
1024
1024
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
1025
1025
|
}
|
|
1026
1026
|
function pushNode(nodes, node) {
|
|
1027
|
-
if (node.type ===
|
|
1027
|
+
if (node.type === 2) {
|
|
1028
1028
|
const prev = last(nodes);
|
|
1029
|
-
if (prev && prev.type ===
|
|
1029
|
+
if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
|
|
1030
1030
|
prev.content += node.content;
|
|
1031
1031
|
prev.loc.end = node.loc.end;
|
|
1032
1032
|
prev.loc.source += node.loc.source;
|
|
@@ -1073,7 +1073,7 @@ function parseComment(context) {
|
|
|
1073
1073
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
1074
1074
|
}
|
|
1075
1075
|
return {
|
|
1076
|
-
type:
|
|
1076
|
+
type: 3,
|
|
1077
1077
|
content,
|
|
1078
1078
|
loc: getSelection(context, start)
|
|
1079
1079
|
};
|
|
@@ -1091,7 +1091,7 @@ function parseBogusComment(context) {
|
|
|
1091
1091
|
advanceBy(context, closeIndex + 1);
|
|
1092
1092
|
}
|
|
1093
1093
|
return {
|
|
1094
|
-
type:
|
|
1094
|
+
type: 3,
|
|
1095
1095
|
content,
|
|
1096
1096
|
loc: getSelection(context, start)
|
|
1097
1097
|
};
|
|
@@ -1127,7 +1127,7 @@ function parseElement(context, ancestors) {
|
|
|
1127
1127
|
)) {
|
|
1128
1128
|
const loc = getSelection(context, element.loc.end);
|
|
1129
1129
|
inlineTemplateProp.value = {
|
|
1130
|
-
type:
|
|
1130
|
+
type: 2,
|
|
1131
1131
|
content: loc.source,
|
|
1132
1132
|
loc
|
|
1133
1133
|
};
|
|
@@ -1234,7 +1234,7 @@ function parseTag(context, type, parent) {
|
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
1236
1236
|
return {
|
|
1237
|
-
type:
|
|
1237
|
+
type: 1,
|
|
1238
1238
|
ns,
|
|
1239
1239
|
tag,
|
|
1240
1240
|
tagType,
|
|
@@ -1440,7 +1440,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1440
1440
|
type: 6,
|
|
1441
1441
|
name,
|
|
1442
1442
|
value: value && {
|
|
1443
|
-
type:
|
|
1443
|
+
type: 2,
|
|
1444
1444
|
content: value.content,
|
|
1445
1445
|
loc: value.loc
|
|
1446
1446
|
},
|
|
@@ -1530,7 +1530,7 @@ function parseText(context, mode) {
|
|
|
1530
1530
|
const start = getCursor(context);
|
|
1531
1531
|
const content = parseTextData(context, endIndex, mode);
|
|
1532
1532
|
return {
|
|
1533
|
-
type:
|
|
1533
|
+
type: 2,
|
|
1534
1534
|
content,
|
|
1535
1535
|
loc: getSelection(context, start)
|
|
1536
1536
|
};
|
|
@@ -1639,7 +1639,7 @@ function hoistStatic(root, context) {
|
|
|
1639
1639
|
}
|
|
1640
1640
|
function isSingleElementRoot(root, child) {
|
|
1641
1641
|
const { children } = root;
|
|
1642
|
-
return children.length === 1 && child.type ===
|
|
1642
|
+
return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
|
1643
1643
|
}
|
|
1644
1644
|
function walk(node, context, doNotHoistNode = false) {
|
|
1645
1645
|
const { children } = node;
|
|
@@ -1647,7 +1647,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1647
1647
|
let hoistedCount = 0;
|
|
1648
1648
|
for (let i = 0; i < children.length; i++) {
|
|
1649
1649
|
const child = children[i];
|
|
1650
|
-
if (child.type ===
|
|
1650
|
+
if (child.type === 1 && child.tagType === 0) {
|
|
1651
1651
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
1652
1652
|
if (constantType > 0) {
|
|
1653
1653
|
if (constantType >= 2) {
|
|
@@ -1672,7 +1672,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1672
1672
|
}
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
|
-
if (child.type ===
|
|
1675
|
+
if (child.type === 1) {
|
|
1676
1676
|
const isComponent = child.tagType === 1;
|
|
1677
1677
|
if (isComponent) {
|
|
1678
1678
|
context.scopes.vSlot++;
|
|
@@ -1696,7 +1696,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1696
1696
|
if (hoistedCount && context.transformHoist) {
|
|
1697
1697
|
context.transformHoist(children, context, node);
|
|
1698
1698
|
}
|
|
1699
|
-
if (hoistedCount && hoistedCount === originalCount && node.type ===
|
|
1699
|
+
if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
|
1700
1700
|
node.codegenNode.children = context.hoist(
|
|
1701
1701
|
createArrayExpression(node.codegenNode.children)
|
|
1702
1702
|
);
|
|
@@ -1705,7 +1705,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1705
1705
|
function getConstantType(node, context) {
|
|
1706
1706
|
const { constantCache } = context;
|
|
1707
1707
|
switch (node.type) {
|
|
1708
|
-
case
|
|
1708
|
+
case 1:
|
|
1709
1709
|
if (node.tagType !== 0) {
|
|
1710
1710
|
return 0;
|
|
1711
1711
|
}
|
|
@@ -1777,8 +1777,8 @@ function getConstantType(node, context) {
|
|
|
1777
1777
|
constantCache.set(node, 0);
|
|
1778
1778
|
return 0;
|
|
1779
1779
|
}
|
|
1780
|
-
case
|
|
1781
|
-
case
|
|
1780
|
+
case 2:
|
|
1781
|
+
case 3:
|
|
1782
1782
|
return 3;
|
|
1783
1783
|
case 9:
|
|
1784
1784
|
case 11:
|
|
@@ -2052,7 +2052,7 @@ function createRootCodegen(root, context) {
|
|
|
2052
2052
|
} else if (children.length > 1) {
|
|
2053
2053
|
let patchFlag = 64;
|
|
2054
2054
|
let patchFlagText = PatchFlagNames[64];
|
|
2055
|
-
if (children.filter((c) => c.type !==
|
|
2055
|
+
if (children.filter((c) => c.type !== 3).length === 1) {
|
|
2056
2056
|
patchFlag |= 2048;
|
|
2057
2057
|
patchFlagText += `, ${PatchFlagNames[2048]}`;
|
|
2058
2058
|
}
|
|
@@ -2106,7 +2106,7 @@ function traverseNode(node, context) {
|
|
|
2106
2106
|
}
|
|
2107
2107
|
}
|
|
2108
2108
|
switch (node.type) {
|
|
2109
|
-
case
|
|
2109
|
+
case 3:
|
|
2110
2110
|
if (!context.ssr) {
|
|
2111
2111
|
context.helper(CREATE_COMMENT);
|
|
2112
2112
|
}
|
|
@@ -2123,7 +2123,7 @@ function traverseNode(node, context) {
|
|
|
2123
2123
|
break;
|
|
2124
2124
|
case 10:
|
|
2125
2125
|
case 11:
|
|
2126
|
-
case
|
|
2126
|
+
case 1:
|
|
2127
2127
|
case 0:
|
|
2128
2128
|
traverseChildren(node, context);
|
|
2129
2129
|
break;
|
|
@@ -2137,7 +2137,7 @@ function traverseNode(node, context) {
|
|
|
2137
2137
|
function createStructuralDirectiveTransform(name, fn) {
|
|
2138
2138
|
const matches = isString(name) ? (n) => n === name : (n) => name.test(n);
|
|
2139
2139
|
return (node, context) => {
|
|
2140
|
-
if (node.type ===
|
|
2140
|
+
if (node.type === 1) {
|
|
2141
2141
|
const { props } = node;
|
|
2142
2142
|
if (node.tagType === 3 && props.some(isVSlot)) {
|
|
2143
2143
|
return;
|
|
@@ -2380,7 +2380,7 @@ function genHoists(hoists, context) {
|
|
|
2380
2380
|
context.pure = false;
|
|
2381
2381
|
}
|
|
2382
2382
|
function isText(n) {
|
|
2383
|
-
return isString(n) || n.type === 4 || n.type ===
|
|
2383
|
+
return isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
|
2384
2384
|
}
|
|
2385
2385
|
function genNodeListAsArray(nodes, context) {
|
|
2386
2386
|
const multilines = nodes.length > 3 || nodes.some((n) => isArray(n) || !isText(n));
|
|
@@ -2421,7 +2421,7 @@ function genNode(node, context) {
|
|
|
2421
2421
|
return;
|
|
2422
2422
|
}
|
|
2423
2423
|
switch (node.type) {
|
|
2424
|
-
case
|
|
2424
|
+
case 1:
|
|
2425
2425
|
case 9:
|
|
2426
2426
|
case 11:
|
|
2427
2427
|
assert(
|
|
@@ -2430,7 +2430,7 @@ function genNode(node, context) {
|
|
|
2430
2430
|
);
|
|
2431
2431
|
genNode(node.codegenNode, context);
|
|
2432
2432
|
break;
|
|
2433
|
-
case
|
|
2433
|
+
case 2:
|
|
2434
2434
|
genText(node, context);
|
|
2435
2435
|
break;
|
|
2436
2436
|
case 4:
|
|
@@ -2445,7 +2445,7 @@ function genNode(node, context) {
|
|
|
2445
2445
|
case 8:
|
|
2446
2446
|
genCompoundExpression(node, context);
|
|
2447
2447
|
break;
|
|
2448
|
-
case
|
|
2448
|
+
case 3:
|
|
2449
2449
|
genComment(node, context);
|
|
2450
2450
|
break;
|
|
2451
2451
|
case 13:
|
|
@@ -2841,7 +2841,7 @@ const transformExpression = (node, context) => {
|
|
|
2841
2841
|
node.content,
|
|
2842
2842
|
context
|
|
2843
2843
|
);
|
|
2844
|
-
} else if (node.type ===
|
|
2844
|
+
} else if (node.type === 1) {
|
|
2845
2845
|
for (let i = 0; i < node.props.length; i++) {
|
|
2846
2846
|
const dir = node.props[i];
|
|
2847
2847
|
if (dir.type === 7 && dir.name !== "for") {
|
|
@@ -2940,12 +2940,12 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2940
2940
|
let i = siblings.indexOf(node);
|
|
2941
2941
|
while (i-- >= -1) {
|
|
2942
2942
|
const sibling = siblings[i];
|
|
2943
|
-
if (sibling && sibling.type ===
|
|
2943
|
+
if (sibling && sibling.type === 3) {
|
|
2944
2944
|
context.removeNode(sibling);
|
|
2945
2945
|
comments.unshift(sibling);
|
|
2946
2946
|
continue;
|
|
2947
2947
|
}
|
|
2948
|
-
if (sibling && sibling.type ===
|
|
2948
|
+
if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
|
2949
2949
|
context.removeNode(sibling);
|
|
2950
2950
|
continue;
|
|
2951
2951
|
}
|
|
@@ -2958,7 +2958,7 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
2958
2958
|
context.removeNode();
|
|
2959
2959
|
const branch = createIfBranch(node, dir);
|
|
2960
2960
|
if (comments.length && // #3619 ignore comments if the v-if is direct child of <transition>
|
|
2961
|
-
!(context.parent && context.parent.type ===
|
|
2961
|
+
!(context.parent && context.parent.type === 1 && isBuiltInType(context.parent.tag, "transition"))) {
|
|
2962
2962
|
branch.children = [...comments, ...branch.children];
|
|
2963
2963
|
}
|
|
2964
2964
|
{
|
|
@@ -3031,7 +3031,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3031
3031
|
);
|
|
3032
3032
|
const { children } = branch;
|
|
3033
3033
|
const firstChild = children[0];
|
|
3034
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !==
|
|
3034
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
|
|
3035
3035
|
if (needFragmentWrapper) {
|
|
3036
3036
|
if (children.length === 1 && firstChild.type === 11) {
|
|
3037
3037
|
const vnodeCall = firstChild.codegenNode;
|
|
@@ -3040,7 +3040,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3040
3040
|
} else {
|
|
3041
3041
|
let patchFlag = 64;
|
|
3042
3042
|
let patchFlagText = PatchFlagNames[64];
|
|
3043
|
-
if (!branch.isTemplateIf && children.filter((c) => c.type !==
|
|
3043
|
+
if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
|
|
3044
3044
|
patchFlag |= 2048;
|
|
3045
3045
|
patchFlagText += `, ${PatchFlagNames[2048]}`;
|
|
3046
3046
|
}
|
|
@@ -3135,7 +3135,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3135
3135
|
const { children } = forNode;
|
|
3136
3136
|
if (isTemplate) {
|
|
3137
3137
|
node.children.some((c) => {
|
|
3138
|
-
if (c.type ===
|
|
3138
|
+
if (c.type === 1) {
|
|
3139
3139
|
const key = findProp(c, "key");
|
|
3140
3140
|
if (key) {
|
|
3141
3141
|
context.onError(
|
|
@@ -3149,7 +3149,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3149
3149
|
}
|
|
3150
3150
|
});
|
|
3151
3151
|
}
|
|
3152
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !==
|
|
3152
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
|
3153
3153
|
const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
|
3154
3154
|
if (slotOutlet) {
|
|
3155
3155
|
childBlock = slotOutlet.codegenNode;
|
|
@@ -3368,7 +3368,7 @@ function createParamsList(args) {
|
|
|
3368
3368
|
|
|
3369
3369
|
const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
3370
3370
|
const trackSlotScopes = (node, context) => {
|
|
3371
|
-
if (node.type ===
|
|
3371
|
+
if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
|
3372
3372
|
const vSlot = findDir(node, "slot");
|
|
3373
3373
|
if (vSlot) {
|
|
3374
3374
|
vSlot.exp;
|
|
@@ -3435,7 +3435,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3435
3435
|
const slotElement = children[i];
|
|
3436
3436
|
let slotDir;
|
|
3437
3437
|
if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
|
3438
|
-
if (slotElement.type !==
|
|
3438
|
+
if (slotElement.type !== 3) {
|
|
3439
3439
|
implicitDefaultChildren.push(slotElement);
|
|
3440
3440
|
}
|
|
3441
3441
|
continue;
|
|
@@ -3482,7 +3482,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3482
3482
|
let prev;
|
|
3483
3483
|
while (j--) {
|
|
3484
3484
|
prev = children[j];
|
|
3485
|
-
if (prev.type !==
|
|
3485
|
+
if (prev.type !== 3) {
|
|
3486
3486
|
break;
|
|
3487
3487
|
}
|
|
3488
3488
|
}
|
|
@@ -3616,7 +3616,7 @@ function hasForwardedSlots(children) {
|
|
|
3616
3616
|
for (let i = 0; i < children.length; i++) {
|
|
3617
3617
|
const child = children[i];
|
|
3618
3618
|
switch (child.type) {
|
|
3619
|
-
case
|
|
3619
|
+
case 1:
|
|
3620
3620
|
if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
|
3621
3621
|
return true;
|
|
3622
3622
|
}
|
|
@@ -3635,16 +3635,16 @@ function hasForwardedSlots(children) {
|
|
|
3635
3635
|
return false;
|
|
3636
3636
|
}
|
|
3637
3637
|
function isNonWhitespaceContent(node) {
|
|
3638
|
-
if (node.type !==
|
|
3638
|
+
if (node.type !== 2 && node.type !== 12)
|
|
3639
3639
|
return true;
|
|
3640
|
-
return node.type ===
|
|
3640
|
+
return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
|
3641
3641
|
}
|
|
3642
3642
|
|
|
3643
3643
|
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
3644
3644
|
const transformElement = (node, context) => {
|
|
3645
3645
|
return function postTransformElement() {
|
|
3646
3646
|
node = context.currentNode;
|
|
3647
|
-
if (!(node.type ===
|
|
3647
|
+
if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
|
|
3648
3648
|
return;
|
|
3649
3649
|
}
|
|
3650
3650
|
const { tag, props } = node;
|
|
@@ -3715,7 +3715,7 @@ const transformElement = (node, context) => {
|
|
|
3715
3715
|
if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
|
3716
3716
|
patchFlag |= 1;
|
|
3717
3717
|
}
|
|
3718
|
-
if (hasDynamicTextChild || type ===
|
|
3718
|
+
if (hasDynamicTextChild || type === 2) {
|
|
3719
3719
|
vnodeChildren = child;
|
|
3720
3720
|
} else {
|
|
3721
3721
|
vnodeChildren = node.children;
|
|
@@ -4399,7 +4399,7 @@ const injectPrefix = (arg, prefix) => {
|
|
|
4399
4399
|
};
|
|
4400
4400
|
|
|
4401
4401
|
const transformText = (node, context) => {
|
|
4402
|
-
if (node.type === 0 || node.type ===
|
|
4402
|
+
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
4403
4403
|
return () => {
|
|
4404
4404
|
const children = node.children;
|
|
4405
4405
|
let currentContainer = void 0;
|
|
@@ -4431,7 +4431,7 @@ const transformText = (node, context) => {
|
|
|
4431
4431
|
// as-is since the runtime has dedicated fast path for this by directly
|
|
4432
4432
|
// setting textContent of the element.
|
|
4433
4433
|
// for component root it's always normalized anyway.
|
|
4434
|
-
children.length === 1 && (node.type === 0 || node.type ===
|
|
4434
|
+
children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
|
|
4435
4435
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
4436
4436
|
// we need to avoid setting textContent of the element at runtime
|
|
4437
4437
|
// to avoid accidentally overwriting the DOM elements added
|
|
@@ -4448,7 +4448,7 @@ const transformText = (node, context) => {
|
|
|
4448
4448
|
const child = children[i];
|
|
4449
4449
|
if (isText$1(child) || child.type === 8) {
|
|
4450
4450
|
const callArgs = [];
|
|
4451
|
-
if (child.type !==
|
|
4451
|
+
if (child.type !== 2 || child.content !== " ") {
|
|
4452
4452
|
callArgs.push(child);
|
|
4453
4453
|
}
|
|
4454
4454
|
if (!context.ssr && getConstantType(child, context) === 0) {
|
|
@@ -4473,7 +4473,7 @@ const transformText = (node, context) => {
|
|
|
4473
4473
|
|
|
4474
4474
|
const seen$1 = /* @__PURE__ */ new WeakSet();
|
|
4475
4475
|
const transformOnce = (node, context) => {
|
|
4476
|
-
if (node.type ===
|
|
4476
|
+
if (node.type === 1 && findDir(node, "once", true)) {
|
|
4477
4477
|
if (seen$1.has(node) || context.inVOnce) {
|
|
4478
4478
|
return;
|
|
4479
4479
|
}
|
|
@@ -4562,7 +4562,7 @@ const transformFilter = (node, context) => {
|
|
|
4562
4562
|
if (node.type === 5) {
|
|
4563
4563
|
rewriteFilter(node.content, context);
|
|
4564
4564
|
}
|
|
4565
|
-
if (node.type ===
|
|
4565
|
+
if (node.type === 1) {
|
|
4566
4566
|
node.props.forEach((prop) => {
|
|
4567
4567
|
if (prop.type === 7 && prop.name !== "for" && prop.exp) {
|
|
4568
4568
|
rewriteFilter(prop.exp, context);
|
|
@@ -4703,7 +4703,7 @@ function wrapFilter(exp, filter, context) {
|
|
|
4703
4703
|
|
|
4704
4704
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
4705
4705
|
const transformMemo = (node, context) => {
|
|
4706
|
-
if (node.type ===
|
|
4706
|
+
if (node.type === 1) {
|
|
4707
4707
|
const dir = findDir(node, "memo");
|
|
4708
4708
|
if (!dir || seen.has(node)) {
|
|
4709
4709
|
return;
|
|
@@ -4892,7 +4892,7 @@ const parserOptions = {
|
|
|
4892
4892
|
};
|
|
4893
4893
|
|
|
4894
4894
|
const transformStyle = (node) => {
|
|
4895
|
-
if (node.type ===
|
|
4895
|
+
if (node.type === 1) {
|
|
4896
4896
|
node.props.forEach((p, i) => {
|
|
4897
4897
|
if (p.type === 6 && p.name === "style" && p.value) {
|
|
4898
4898
|
node.props[i] = {
|
|
@@ -5182,7 +5182,7 @@ const transformShow = (dir, node, context) => {
|
|
|
5182
5182
|
};
|
|
5183
5183
|
|
|
5184
5184
|
const transformTransition = (node, context) => {
|
|
5185
|
-
if (node.type ===
|
|
5185
|
+
if (node.type === 1 && node.tagType === 1) {
|
|
5186
5186
|
const component = context.isBuiltInComponent(node.tag);
|
|
5187
5187
|
if (component === TRANSITION) {
|
|
5188
5188
|
return () => {
|
|
@@ -5202,7 +5202,7 @@ const transformTransition = (node, context) => {
|
|
|
5202
5202
|
);
|
|
5203
5203
|
}
|
|
5204
5204
|
const child = node.children[0];
|
|
5205
|
-
if (child.type ===
|
|
5205
|
+
if (child.type === 1) {
|
|
5206
5206
|
for (const p of child.props) {
|
|
5207
5207
|
if (p.type === 7 && p.name === "show") {
|
|
5208
5208
|
node.props.push({
|
|
@@ -5220,14 +5220,14 @@ const transformTransition = (node, context) => {
|
|
|
5220
5220
|
};
|
|
5221
5221
|
function hasMultipleChildren(node) {
|
|
5222
5222
|
const children = node.children = node.children.filter(
|
|
5223
|
-
(c) => c.type !==
|
|
5223
|
+
(c) => c.type !== 3 && !(c.type === 2 && !c.content.trim())
|
|
5224
5224
|
);
|
|
5225
5225
|
const child = children[0];
|
|
5226
5226
|
return children.length !== 1 || child.type === 11 || child.type === 9 && child.branches.some(hasMultipleChildren);
|
|
5227
5227
|
}
|
|
5228
5228
|
|
|
5229
5229
|
const ignoreSideEffectTags = (node, context) => {
|
|
5230
|
-
if (node.type ===
|
|
5230
|
+
if (node.type === 1 && node.tagType === 0 && (node.tag === "script" || node.tag === "style")) {
|
|
5231
5231
|
context.onError(
|
|
5232
5232
|
createDOMCompilerError(61, node.loc)
|
|
5233
5233
|
);
|