@vue/compiler-vapor 3.6.0-alpha.7 → 3.6.0-beta.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/compiler-vapor.cjs.js +214 -47
- package/dist/compiler-vapor.d.ts +4 -0
- package/dist/compiler-vapor.esm-browser.js +2531 -276
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-vapor v3.6.0-
|
|
2
|
+
* @vue/compiler-vapor v3.6.0-beta.2
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -149,6 +149,8 @@ class TransformContext {
|
|
|
149
149
|
this.node = node;
|
|
150
150
|
this.selfName = null;
|
|
151
151
|
this.parent = null;
|
|
152
|
+
// cached parent that skips template tags
|
|
153
|
+
this.effectiveParent = null;
|
|
152
154
|
this.index = 0;
|
|
153
155
|
this.block = this.ir.block;
|
|
154
156
|
this.template = "";
|
|
@@ -161,6 +163,12 @@ class TransformContext {
|
|
|
161
163
|
this.component = this.ir.component;
|
|
162
164
|
this.directive = this.ir.directive;
|
|
163
165
|
this.slots = [];
|
|
166
|
+
// whether this node is the last effective child of its parent
|
|
167
|
+
// (all siblings after it are components, which don't appear in HTML template)
|
|
168
|
+
this.isLastEffectiveChild = true;
|
|
169
|
+
// whether this node is on the rightmost path of the tree
|
|
170
|
+
// (all ancestors are also last effective children)
|
|
171
|
+
this.isOnRightmostPath = true;
|
|
164
172
|
this.globalId = 0;
|
|
165
173
|
this.nextIdMap = null;
|
|
166
174
|
this.increaseId = () => {
|
|
@@ -241,15 +249,31 @@ class TransformContext {
|
|
|
241
249
|
this.block.operation.push(...node);
|
|
242
250
|
}
|
|
243
251
|
create(node, index) {
|
|
252
|
+
let effectiveParent = this;
|
|
253
|
+
while (effectiveParent && effectiveParent.node.type === 1 && effectiveParent.node.tagType === 3) {
|
|
254
|
+
effectiveParent = effectiveParent.parent;
|
|
255
|
+
}
|
|
256
|
+
const isLastEffectiveChild = this.isEffectivelyLastChild(index);
|
|
257
|
+
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild;
|
|
244
258
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
245
259
|
node,
|
|
246
260
|
parent: this,
|
|
247
261
|
index,
|
|
248
262
|
template: "",
|
|
249
263
|
childrenTemplate: [],
|
|
250
|
-
dynamic: newDynamic()
|
|
264
|
+
dynamic: newDynamic(),
|
|
265
|
+
effectiveParent,
|
|
266
|
+
isLastEffectiveChild,
|
|
267
|
+
isOnRightmostPath
|
|
251
268
|
});
|
|
252
269
|
}
|
|
270
|
+
isEffectivelyLastChild(index) {
|
|
271
|
+
const children = this.node.children;
|
|
272
|
+
if (!children) return true;
|
|
273
|
+
return children.every(
|
|
274
|
+
(c, i) => i <= index || c.type === 1 && c.tagType === 1
|
|
275
|
+
);
|
|
276
|
+
}
|
|
253
277
|
}
|
|
254
278
|
const defaultOptions = {
|
|
255
279
|
filename: "",
|
|
@@ -370,10 +394,10 @@ const IMPORT_EXPR_RE = new RegExp(
|
|
|
370
394
|
`${IMPORT_EXP_START}(.*?)${IMPORT_EXP_END}`,
|
|
371
395
|
"g"
|
|
372
396
|
);
|
|
373
|
-
const NEWLINE = Symbol(`newline` );
|
|
374
|
-
const LF = Symbol(`line feed` );
|
|
375
|
-
const INDENT_START = Symbol(`indent start` );
|
|
376
|
-
const INDENT_END = Symbol(`indent end` );
|
|
397
|
+
const NEWLINE = /* @__PURE__ */ Symbol(`newline` );
|
|
398
|
+
const LF = /* @__PURE__ */ Symbol(`line feed` );
|
|
399
|
+
const INDENT_START = /* @__PURE__ */ Symbol(`indent start` );
|
|
400
|
+
const INDENT_END = /* @__PURE__ */ Symbol(`indent end` );
|
|
377
401
|
function buildCodeFragment(...frag) {
|
|
378
402
|
const push = frag.push.bind(frag);
|
|
379
403
|
const unshift = frag.unshift.bind(frag);
|
|
@@ -789,6 +813,10 @@ function analyzeExpressions(expressions) {
|
|
|
789
813
|
end: id.end
|
|
790
814
|
});
|
|
791
815
|
});
|
|
816
|
+
const parentOfMemberExp = parentStack[parentStack.length - 2];
|
|
817
|
+
if (parentOfMemberExp && isCallExpression(parentOfMemberExp)) {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
792
820
|
registerVariable(
|
|
793
821
|
memberExp,
|
|
794
822
|
exp,
|
|
@@ -1005,6 +1033,8 @@ function extractMemberExpression(exp, onIdentifier) {
|
|
|
1005
1033
|
return `${extractMemberExpression(exp.left, onIdentifier)} ${exp.operator} ${extractMemberExpression(exp.right, onIdentifier)}`;
|
|
1006
1034
|
case "CallExpression":
|
|
1007
1035
|
return `${extractMemberExpression(exp.callee, onIdentifier)}(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
|
|
1036
|
+
case "OptionalCallExpression":
|
|
1037
|
+
return `${extractMemberExpression(exp.callee, onIdentifier)}?.(${exp.arguments.map((arg) => extractMemberExpression(arg, onIdentifier)).join(", ")})`;
|
|
1008
1038
|
case "MemberExpression":
|
|
1009
1039
|
// foo[bar.baz]
|
|
1010
1040
|
case "OptionalMemberExpression":
|
|
@@ -1017,6 +1047,9 @@ function extractMemberExpression(exp, onIdentifier) {
|
|
|
1017
1047
|
return "";
|
|
1018
1048
|
}
|
|
1019
1049
|
}
|
|
1050
|
+
const isCallExpression = (node) => {
|
|
1051
|
+
return node.type === "CallExpression" || node.type === "OptionalCallExpression";
|
|
1052
|
+
};
|
|
1020
1053
|
const isMemberExpression = (node) => {
|
|
1021
1054
|
return node.type === "MemberExpression" || node.type === "OptionalMemberExpression" || node.type === "TSNonNullExpression";
|
|
1022
1055
|
};
|
|
@@ -1084,7 +1117,7 @@ function genSetDynamicEvents(oper, context) {
|
|
|
1084
1117
|
)
|
|
1085
1118
|
];
|
|
1086
1119
|
}
|
|
1087
|
-
function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] }, extraWrap = false) {
|
|
1120
|
+
function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] }, asComponentProp = false, extraWrap = false) {
|
|
1088
1121
|
let handlerExp = [];
|
|
1089
1122
|
if (values) {
|
|
1090
1123
|
values.forEach((value, index) => {
|
|
@@ -1092,7 +1125,7 @@ function genEventHandler(context, values, modifiers = { nonKeys: [], keys: [] },
|
|
|
1092
1125
|
if (value && value.content.trim()) {
|
|
1093
1126
|
if (compilerDom.isMemberExpression(value, context.options)) {
|
|
1094
1127
|
exp = genExpression(value, context);
|
|
1095
|
-
if (!isConstantBinding(value, context) && !
|
|
1128
|
+
if (!isConstantBinding(value, context) && !asComponentProp) {
|
|
1096
1129
|
const isTSNode = value.ast && compilerDom.TS_NODE_TYPES.includes(value.ast.type);
|
|
1097
1130
|
exp = [
|
|
1098
1131
|
`e => `,
|
|
@@ -1622,7 +1655,7 @@ function genPropKey({ key: node, modifier, runtimeCamelize, handler, handlerModi
|
|
|
1622
1655
|
const { helper } = context;
|
|
1623
1656
|
const handlerModifierPostfix = handlerModifiers && handlerModifiers.options ? handlerModifiers.options.map(shared.capitalize).join("") : "";
|
|
1624
1657
|
if (node.isStatic) {
|
|
1625
|
-
const keyName = (handler ? shared.toHandlerKey(node.content) : node.content) + handlerModifierPostfix;
|
|
1658
|
+
const keyName = (handler ? shared.toHandlerKey(shared.camelize(node.content)) : node.content) + handlerModifierPostfix;
|
|
1626
1659
|
return [
|
|
1627
1660
|
[
|
|
1628
1661
|
compilerDom.isSimpleIdentifier(keyName) ? keyName : JSON.stringify(keyName),
|
|
@@ -1875,7 +1908,7 @@ function genCreateComponent(operation, context) {
|
|
|
1875
1908
|
const rawProps = context.withId(() => genRawProps(props, context), ids);
|
|
1876
1909
|
const inlineHandlers = handlers.reduce(
|
|
1877
1910
|
(acc, { name, value }) => {
|
|
1878
|
-
const handler = genEventHandler(context, [value], void 0, false);
|
|
1911
|
+
const handler = genEventHandler(context, [value], void 0, false, false);
|
|
1879
1912
|
return [...acc, `const ${name} = `, ...handler, NEWLINE];
|
|
1880
1913
|
},
|
|
1881
1914
|
[]
|
|
@@ -1969,7 +2002,89 @@ function genRawProps(props, context) {
|
|
|
1969
2002
|
}
|
|
1970
2003
|
}
|
|
1971
2004
|
function genStaticProps(props, context, dynamicProps) {
|
|
1972
|
-
const args =
|
|
2005
|
+
const args = [];
|
|
2006
|
+
const handlerGroups = /* @__PURE__ */ new Map();
|
|
2007
|
+
const ensureHandlerGroup = (keyName, keyFrag) => {
|
|
2008
|
+
let group = handlerGroups.get(keyName);
|
|
2009
|
+
if (!group) {
|
|
2010
|
+
const index = args.length;
|
|
2011
|
+
args.push([]);
|
|
2012
|
+
group = { keyFrag, handlers: [], index };
|
|
2013
|
+
handlerGroups.set(keyName, group);
|
|
2014
|
+
}
|
|
2015
|
+
return group;
|
|
2016
|
+
};
|
|
2017
|
+
const addHandler = (keyName, keyFrag, handlerExp) => {
|
|
2018
|
+
ensureHandlerGroup(keyName, keyFrag).handlers.push(handlerExp);
|
|
2019
|
+
};
|
|
2020
|
+
const getStaticPropKeyName = (prop) => {
|
|
2021
|
+
if (!prop.key.isStatic) return;
|
|
2022
|
+
const handlerModifierPostfix = prop.handlerModifiers && prop.handlerModifiers.options ? prop.handlerModifiers.options.map((m) => m.charAt(0).toUpperCase() + m.slice(1)).join("") : "";
|
|
2023
|
+
const keyName = (prop.handler ? shared.toHandlerKey(shared.camelize(prop.key.content)) : prop.key.content) + handlerModifierPostfix;
|
|
2024
|
+
return keyName;
|
|
2025
|
+
};
|
|
2026
|
+
for (const prop of props) {
|
|
2027
|
+
if (prop.handler) {
|
|
2028
|
+
const keyName = getStaticPropKeyName(prop);
|
|
2029
|
+
if (!keyName) {
|
|
2030
|
+
args.push(genProp(prop, context, true));
|
|
2031
|
+
continue;
|
|
2032
|
+
}
|
|
2033
|
+
const keyFrag = genPropKey(prop, context);
|
|
2034
|
+
const hasModifiers = !!prop.handlerModifiers && (prop.handlerModifiers.keys.length > 0 || prop.handlerModifiers.nonKeys.length > 0);
|
|
2035
|
+
if (hasModifiers || prop.values.length <= 1) {
|
|
2036
|
+
const handlerExp = genEventHandler(
|
|
2037
|
+
context,
|
|
2038
|
+
prop.values,
|
|
2039
|
+
prop.handlerModifiers,
|
|
2040
|
+
true,
|
|
2041
|
+
false
|
|
2042
|
+
);
|
|
2043
|
+
addHandler(keyName, keyFrag, handlerExp);
|
|
2044
|
+
} else {
|
|
2045
|
+
for (const value of prop.values) {
|
|
2046
|
+
const handlerExp = genEventHandler(
|
|
2047
|
+
context,
|
|
2048
|
+
[value],
|
|
2049
|
+
prop.handlerModifiers,
|
|
2050
|
+
true,
|
|
2051
|
+
false
|
|
2052
|
+
);
|
|
2053
|
+
addHandler(keyName, keyFrag, handlerExp);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
continue;
|
|
2057
|
+
}
|
|
2058
|
+
args.push(genProp(prop, context, true));
|
|
2059
|
+
if (prop.model) {
|
|
2060
|
+
if (prop.key.isStatic) {
|
|
2061
|
+
const keyName = `onUpdate:${shared.camelize(prop.key.content)}`;
|
|
2062
|
+
const keyFrag = [JSON.stringify(keyName)];
|
|
2063
|
+
addHandler(keyName, keyFrag, genModelHandler(prop.values[0], context));
|
|
2064
|
+
} else {
|
|
2065
|
+
const keyFrag = [
|
|
2066
|
+
'["onUpdate:" + ',
|
|
2067
|
+
...genExpression(prop.key, context),
|
|
2068
|
+
"]"
|
|
2069
|
+
];
|
|
2070
|
+
args.push([
|
|
2071
|
+
...keyFrag,
|
|
2072
|
+
": () => ",
|
|
2073
|
+
...genModelHandler(prop.values[0], context)
|
|
2074
|
+
]);
|
|
2075
|
+
}
|
|
2076
|
+
const { key, modelModifiers } = prop;
|
|
2077
|
+
if (modelModifiers && modelModifiers.length) {
|
|
2078
|
+
const modifiersKey = key.isStatic ? [shared.getModifierPropName(key.content)] : ["[", ...genExpression(key, context), ' + "Modifiers"]'];
|
|
2079
|
+
const modifiersVal = genDirectiveModifiers(modelModifiers);
|
|
2080
|
+
args.push([...modifiersKey, `: () => ({ ${modifiersVal} })`]);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
for (const group of handlerGroups.values()) {
|
|
2085
|
+
const handlerValue = group.handlers.length > 1 ? genMulti(DELIMITERS_ARRAY_NEWLINE, ...group.handlers) : group.handlers[0];
|
|
2086
|
+
args[group.index] = [...group.keyFrag, ": () => ", ...handlerValue];
|
|
2087
|
+
}
|
|
1973
2088
|
if (dynamicProps) {
|
|
1974
2089
|
args.push([`$: `, ...dynamicProps]);
|
|
1975
2090
|
}
|
|
@@ -1989,11 +2104,46 @@ function genDynamicProps(props, context) {
|
|
|
1989
2104
|
}
|
|
1990
2105
|
continue;
|
|
1991
2106
|
} else {
|
|
1992
|
-
if (p.kind === 1)
|
|
1993
|
-
|
|
1994
|
-
|
|
2107
|
+
if (p.kind === 1) {
|
|
2108
|
+
if (p.model) {
|
|
2109
|
+
const entries = [genProp(p, context)];
|
|
2110
|
+
const updateKey = p.key.isStatic ? [
|
|
2111
|
+
JSON.stringify(`onUpdate:${shared.camelize(p.key.content)}`)
|
|
2112
|
+
] : [
|
|
2113
|
+
'["onUpdate:" + ',
|
|
2114
|
+
...genExpression(p.key, context),
|
|
2115
|
+
"]"
|
|
2116
|
+
];
|
|
2117
|
+
entries.push([
|
|
2118
|
+
...updateKey,
|
|
2119
|
+
": () => ",
|
|
2120
|
+
...genModelHandler(p.values[0], context)
|
|
2121
|
+
]);
|
|
2122
|
+
const { modelModifiers } = p;
|
|
2123
|
+
if (modelModifiers && modelModifiers.length) {
|
|
2124
|
+
const modifiersKey = p.key.isStatic ? [shared.getModifierPropName(p.key.content)] : [
|
|
2125
|
+
"[",
|
|
2126
|
+
...genExpression(p.key, context),
|
|
2127
|
+
' + "Modifiers"]'
|
|
2128
|
+
];
|
|
2129
|
+
const modifiersVal = genDirectiveModifiers(modelModifiers);
|
|
2130
|
+
entries.push([...modifiersKey, `: () => ({ ${modifiersVal} })`]);
|
|
2131
|
+
}
|
|
2132
|
+
expr = genMulti(DELIMITERS_OBJECT_NEWLINE, ...entries);
|
|
2133
|
+
} else {
|
|
2134
|
+
expr = genMulti(DELIMITERS_OBJECT, genProp(p, context));
|
|
2135
|
+
}
|
|
2136
|
+
} else {
|
|
1995
2137
|
expr = genExpression(p.value, context);
|
|
1996
|
-
if (p.handler)
|
|
2138
|
+
if (p.handler)
|
|
2139
|
+
expr = genCall(
|
|
2140
|
+
helper("toHandlers"),
|
|
2141
|
+
expr,
|
|
2142
|
+
`false`,
|
|
2143
|
+
// preserveCaseIfNecessary: false, not needed for component
|
|
2144
|
+
`true`
|
|
2145
|
+
// wrap handler values in functions
|
|
2146
|
+
);
|
|
1997
2147
|
}
|
|
1998
2148
|
}
|
|
1999
2149
|
frags.push(["() => (", ...expr, ")"]);
|
|
@@ -2011,23 +2161,11 @@ function genProp(prop, context, isStatic) {
|
|
|
2011
2161
|
context,
|
|
2012
2162
|
prop.values,
|
|
2013
2163
|
prop.handlerModifiers,
|
|
2164
|
+
true,
|
|
2014
2165
|
true
|
|
2015
|
-
) : isStatic ? ["() => (", ...values, ")"] : values
|
|
2016
|
-
...prop.model ? [...genModelEvent(prop, context), ...genModelModifiers(prop, context)] : []
|
|
2166
|
+
) : isStatic ? ["() => (", ...values, ")"] : values
|
|
2017
2167
|
];
|
|
2018
2168
|
}
|
|
2019
|
-
function genModelEvent(prop, context) {
|
|
2020
|
-
const name = prop.key.isStatic ? [JSON.stringify(`onUpdate:${shared.camelize(prop.key.content)}`)] : ['["onUpdate:" + ', ...genExpression(prop.key, context), "]"];
|
|
2021
|
-
const handler = genModelHandler(prop.values[0], context);
|
|
2022
|
-
return [",", NEWLINE, ...name, ": () => ", ...handler];
|
|
2023
|
-
}
|
|
2024
|
-
function genModelModifiers(prop, context) {
|
|
2025
|
-
const { key, modelModifiers } = prop;
|
|
2026
|
-
if (!modelModifiers || !modelModifiers.length) return [];
|
|
2027
|
-
const modifiersKey = key.isStatic ? [shared.getModifierPropName(key.content)] : ["[", ...genExpression(key, context), ' + "Modifiers"]'];
|
|
2028
|
-
const modifiersVal = genDirectiveModifiers(modelModifiers);
|
|
2029
|
-
return [",", NEWLINE, ...modifiersKey, `: () => ({ ${modifiersVal} })`];
|
|
2030
|
-
}
|
|
2031
2169
|
function genRawSlots(slots, context) {
|
|
2032
2170
|
if (!slots.length) return;
|
|
2033
2171
|
const staticSlots = slots[0];
|
|
@@ -2466,7 +2604,13 @@ function genChildren(dynamic, context, pushBlock, from = `n${dynamic.id}`) {
|
|
|
2466
2604
|
}
|
|
2467
2605
|
} else {
|
|
2468
2606
|
if (elementIndex === 0) {
|
|
2469
|
-
pushBlock(
|
|
2607
|
+
pushBlock(
|
|
2608
|
+
...genCall(
|
|
2609
|
+
helper("child"),
|
|
2610
|
+
from,
|
|
2611
|
+
logicalIndex !== 0 ? String(logicalIndex) : void 0
|
|
2612
|
+
)
|
|
2613
|
+
);
|
|
2470
2614
|
} else {
|
|
2471
2615
|
let init = genCall(helper("child"), from);
|
|
2472
2616
|
if (elementIndex === 1) {
|
|
@@ -2885,7 +3029,10 @@ const transformElement = (node, context) => {
|
|
|
2885
3029
|
propsResult,
|
|
2886
3030
|
singleRoot,
|
|
2887
3031
|
context,
|
|
2888
|
-
getEffectIndex
|
|
3032
|
+
getEffectIndex,
|
|
3033
|
+
// Root-level elements generate dedicated templates
|
|
3034
|
+
// so closing tags can be omitted
|
|
3035
|
+
context.root === context.effectiveParent || canOmitEndTag(node, context)
|
|
2889
3036
|
);
|
|
2890
3037
|
}
|
|
2891
3038
|
if (parentSlots) {
|
|
@@ -2893,6 +3040,17 @@ const transformElement = (node, context) => {
|
|
|
2893
3040
|
}
|
|
2894
3041
|
};
|
|
2895
3042
|
};
|
|
3043
|
+
function canOmitEndTag(node, context) {
|
|
3044
|
+
const { block, parent } = context;
|
|
3045
|
+
if (!parent) return false;
|
|
3046
|
+
if (block !== parent.block) {
|
|
3047
|
+
return true;
|
|
3048
|
+
}
|
|
3049
|
+
if (shared.isFormattingTag(node.tag) || parent.node.type === 1 && node.tag === parent.node.tag) {
|
|
3050
|
+
return context.isOnRightmostPath;
|
|
3051
|
+
}
|
|
3052
|
+
return context.isLastEffectiveChild;
|
|
3053
|
+
}
|
|
2896
3054
|
function isSingleRoot(context) {
|
|
2897
3055
|
if (context.inVFor) {
|
|
2898
3056
|
return false;
|
|
@@ -2982,7 +3140,8 @@ function resolveSetupReference(name, context) {
|
|
|
2982
3140
|
return bindings[name] ? name : bindings[camelName] ? camelName : bindings[PascalName] ? PascalName : void 0;
|
|
2983
3141
|
}
|
|
2984
3142
|
const dynamicKeys = ["indeterminate"];
|
|
2985
|
-
|
|
3143
|
+
const NEEDS_QUOTES_RE = /[\s"'`=<>]/;
|
|
3144
|
+
function transformNativeElement(node, propsResult, singleRoot, context, getEffectIndex, omitEndTag) {
|
|
2986
3145
|
const { tag } = node;
|
|
2987
3146
|
const { scopeId } = context.options;
|
|
2988
3147
|
let template = "";
|
|
@@ -3002,16 +3161,24 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
3002
3161
|
getEffectIndex
|
|
3003
3162
|
);
|
|
3004
3163
|
} else {
|
|
3164
|
+
let prevWasQuoted = false;
|
|
3005
3165
|
for (const prop of propsResult[1]) {
|
|
3006
3166
|
const { key, values } = prop;
|
|
3007
3167
|
if (context.imports.some(
|
|
3008
3168
|
(imported) => values[0].content.includes(imported.exp.content)
|
|
3009
3169
|
)) {
|
|
3010
|
-
template += `
|
|
3170
|
+
if (!prevWasQuoted) template += ` `;
|
|
3171
|
+
template += `${key.content}="${IMPORT_EXP_START}${values[0].content}${IMPORT_EXP_END}"`;
|
|
3172
|
+
prevWasQuoted = true;
|
|
3011
3173
|
} else if (key.isStatic && values.length === 1 && (values[0].isStatic || values[0].content === "''") && !dynamicKeys.includes(key.content)) {
|
|
3012
|
-
template += `
|
|
3013
|
-
|
|
3014
|
-
|
|
3174
|
+
if (!prevWasQuoted) template += ` `;
|
|
3175
|
+
const value = values[0].content === "''" ? "" : values[0].content;
|
|
3176
|
+
template += key.content;
|
|
3177
|
+
if (value) {
|
|
3178
|
+
template += (prevWasQuoted = NEEDS_QUOTES_RE.test(value)) ? `="${value.replace(/"/g, """)}"` : `=${value}`;
|
|
3179
|
+
} else {
|
|
3180
|
+
prevWasQuoted = false;
|
|
3181
|
+
}
|
|
3015
3182
|
} else {
|
|
3016
3183
|
dynamicProps.push(key.content);
|
|
3017
3184
|
context.registerEffect(
|
|
@@ -3028,7 +3195,7 @@ function transformNativeElement(node, propsResult, singleRoot, context, getEffec
|
|
|
3028
3195
|
}
|
|
3029
3196
|
}
|
|
3030
3197
|
template += `>` + context.childrenTemplate.join("");
|
|
3031
|
-
if (!shared.isVoidTag(tag)) {
|
|
3198
|
+
if (!shared.isVoidTag(tag) && !omitEndTag) {
|
|
3032
3199
|
template += `</${tag}>`;
|
|
3033
3200
|
}
|
|
3034
3201
|
if (singleRoot) {
|
|
@@ -3193,13 +3360,13 @@ const transformVHtml = (dir, node, context) => {
|
|
|
3193
3360
|
let { exp, loc } = dir;
|
|
3194
3361
|
if (!exp) {
|
|
3195
3362
|
context.options.onError(
|
|
3196
|
-
compilerDom.createDOMCompilerError(
|
|
3363
|
+
compilerDom.createDOMCompilerError(54, loc)
|
|
3197
3364
|
);
|
|
3198
3365
|
exp = EMPTY_EXPRESSION;
|
|
3199
3366
|
}
|
|
3200
3367
|
if (node.children.length) {
|
|
3201
3368
|
context.options.onError(
|
|
3202
|
-
compilerDom.createDOMCompilerError(
|
|
3369
|
+
compilerDom.createDOMCompilerError(55, loc)
|
|
3203
3370
|
);
|
|
3204
3371
|
context.childrenTemplate.length = 0;
|
|
3205
3372
|
}
|
|
@@ -3225,13 +3392,13 @@ const transformVText = (dir, node, context) => {
|
|
|
3225
3392
|
let { exp, loc } = dir;
|
|
3226
3393
|
if (!exp) {
|
|
3227
3394
|
context.options.onError(
|
|
3228
|
-
compilerDom.createDOMCompilerError(
|
|
3395
|
+
compilerDom.createDOMCompilerError(56, loc)
|
|
3229
3396
|
);
|
|
3230
3397
|
exp = EMPTY_EXPRESSION;
|
|
3231
3398
|
}
|
|
3232
3399
|
if (node.children.length) {
|
|
3233
3400
|
context.options.onError(
|
|
3234
|
-
compilerDom.createDOMCompilerError(
|
|
3401
|
+
compilerDom.createDOMCompilerError(57, loc)
|
|
3235
3402
|
);
|
|
3236
3403
|
context.childrenTemplate.length = 0;
|
|
3237
3404
|
}
|
|
@@ -3264,7 +3431,7 @@ function normalizeBindShorthand(arg, context) {
|
|
|
3264
3431
|
if (arg.type !== 4 || !arg.isStatic) {
|
|
3265
3432
|
context.options.onError(
|
|
3266
3433
|
compilerDom.createCompilerError(
|
|
3267
|
-
|
|
3434
|
+
53,
|
|
3268
3435
|
arg.loc
|
|
3269
3436
|
)
|
|
3270
3437
|
);
|
|
@@ -3381,7 +3548,7 @@ const transformVShow = (dir, node, context) => {
|
|
|
3381
3548
|
const { exp, loc } = dir;
|
|
3382
3549
|
if (!exp) {
|
|
3383
3550
|
context.options.onError(
|
|
3384
|
-
compilerDom.createDOMCompilerError(
|
|
3551
|
+
compilerDom.createDOMCompilerError(62, loc)
|
|
3385
3552
|
);
|
|
3386
3553
|
return;
|
|
3387
3554
|
}
|
|
@@ -3580,7 +3747,7 @@ const transformVModel = (dir, node, context) => {
|
|
|
3580
3747
|
if (dir.arg)
|
|
3581
3748
|
context.options.onError(
|
|
3582
3749
|
compilerDom.createDOMCompilerError(
|
|
3583
|
-
|
|
3750
|
+
59,
|
|
3584
3751
|
dir.arg.loc
|
|
3585
3752
|
)
|
|
3586
3753
|
);
|
|
@@ -3605,7 +3772,7 @@ const transformVModel = (dir, node, context) => {
|
|
|
3605
3772
|
modelType = void 0;
|
|
3606
3773
|
context.options.onError(
|
|
3607
3774
|
compilerDom.createDOMCompilerError(
|
|
3608
|
-
|
|
3775
|
+
60,
|
|
3609
3776
|
dir.loc
|
|
3610
3777
|
)
|
|
3611
3778
|
);
|
|
@@ -3628,7 +3795,7 @@ const transformVModel = (dir, node, context) => {
|
|
|
3628
3795
|
} else {
|
|
3629
3796
|
context.options.onError(
|
|
3630
3797
|
compilerDom.createDOMCompilerError(
|
|
3631
|
-
|
|
3798
|
+
58,
|
|
3632
3799
|
dir.loc
|
|
3633
3800
|
)
|
|
3634
3801
|
);
|
|
@@ -3647,7 +3814,7 @@ const transformVModel = (dir, node, context) => {
|
|
|
3647
3814
|
if (value && compilerDom.isStaticArgOf(value.arg, "value")) {
|
|
3648
3815
|
context.options.onError(
|
|
3649
3816
|
compilerDom.createDOMCompilerError(
|
|
3650
|
-
|
|
3817
|
+
61,
|
|
3651
3818
|
value.loc
|
|
3652
3819
|
)
|
|
3653
3820
|
);
|
package/dist/compiler-vapor.d.ts
CHANGED
|
@@ -314,6 +314,7 @@ export declare class TransformContext<T extends AllNode = AllNode> {
|
|
|
314
314
|
node: T;
|
|
315
315
|
selfName: string | null;
|
|
316
316
|
parent: TransformContext<RootNode | ElementNode> | null;
|
|
317
|
+
effectiveParent: TransformContext<RootNode | ElementNode> | null;
|
|
317
318
|
root: TransformContext<RootNode>;
|
|
318
319
|
index: number;
|
|
319
320
|
block: BlockIRNode;
|
|
@@ -328,6 +329,8 @@ export declare class TransformContext<T extends AllNode = AllNode> {
|
|
|
328
329
|
component: Set<string>;
|
|
329
330
|
directive: Set<string>;
|
|
330
331
|
slots: IRSlots[];
|
|
332
|
+
isLastEffectiveChild: boolean;
|
|
333
|
+
isOnRightmostPath: boolean;
|
|
331
334
|
private globalId;
|
|
332
335
|
private nextIdMap;
|
|
333
336
|
constructor(ir: RootIRNode, node: T, options?: TransformOptions);
|
|
@@ -340,6 +343,7 @@ export declare class TransformContext<T extends AllNode = AllNode> {
|
|
|
340
343
|
registerEffect(expressions: SimpleExpressionNode[], operation: OperationNode | OperationNode[], getIndex?: () => number): void;
|
|
341
344
|
registerOperation(...node: OperationNode[]): void;
|
|
342
345
|
create<T extends TemplateChildNode>(node: T, index: number): TransformContext<T>;
|
|
346
|
+
private isEffectivelyLastChild;
|
|
343
347
|
}
|
|
344
348
|
export declare function transform(node: RootNode, options?: TransformOptions): RootIRNode;
|
|
345
349
|
export declare function createStructuralDirectiveTransform(name: string | string[], fn: StructuralDirectiveTransform): NodeTransform;
|