@vue/compiler-dom 3.2.33 → 3.2.35
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 +61 -24
- package/dist/compiler-dom.cjs.prod.js +39 -21
- package/dist/compiler-dom.esm-browser.js +42 -26
- package/dist/compiler-dom.esm-browser.prod.js +1 -1
- package/dist/compiler-dom.esm-bundler.js +26 -5
- package/dist/compiler-dom.global.js +42 -25
- package/dist/compiler-dom.global.prod.js +1 -1
- package/package.json +3 -3
package/dist/compiler-dom.cjs.js
CHANGED
|
@@ -2524,7 +2524,9 @@ const transformVText = (dir, node, context) => {
|
|
|
2524
2524
|
return {
|
|
2525
2525
|
props: [
|
|
2526
2526
|
compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`textContent`, true), exp
|
|
2527
|
-
? compilerCore.
|
|
2527
|
+
? compilerCore.getConstantType(exp, context) > 0
|
|
2528
|
+
? exp
|
|
2529
|
+
: compilerCore.createCallExpression(context.helperString(compilerCore.TO_DISPLAY_STRING), [exp], loc)
|
|
2528
2530
|
: compilerCore.createSimpleExpression('', true))
|
|
2529
2531
|
]
|
|
2530
2532
|
};
|
|
@@ -2736,19 +2738,38 @@ const transformShow = (dir, node, context) => {
|
|
|
2736
2738
|
};
|
|
2737
2739
|
};
|
|
2738
2740
|
|
|
2739
|
-
const
|
|
2741
|
+
const transformTransition = (node, context) => {
|
|
2740
2742
|
if (node.type === 1 /* ELEMENT */ &&
|
|
2741
2743
|
node.tagType === 1 /* COMPONENT */) {
|
|
2742
2744
|
const component = context.isBuiltInComponent(node.tag);
|
|
2743
2745
|
if (component === TRANSITION) {
|
|
2744
2746
|
return () => {
|
|
2745
|
-
if (node.children.length
|
|
2747
|
+
if (!node.children.length) {
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
// warn multiple transition children
|
|
2751
|
+
if (hasMultipleChildren(node)) {
|
|
2746
2752
|
context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
|
|
2747
2753
|
start: node.children[0].loc.start,
|
|
2748
2754
|
end: node.children[node.children.length - 1].loc.end,
|
|
2749
2755
|
source: ''
|
|
2750
2756
|
}));
|
|
2751
2757
|
}
|
|
2758
|
+
// check if it's s single child w/ v-show
|
|
2759
|
+
// if yes, inject "persisted: true" to the transition props
|
|
2760
|
+
const child = node.children[0];
|
|
2761
|
+
if (child.type === 1 /* ELEMENT */) {
|
|
2762
|
+
for (const p of child.props) {
|
|
2763
|
+
if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
|
|
2764
|
+
node.props.push({
|
|
2765
|
+
type: 6 /* ATTRIBUTE */,
|
|
2766
|
+
name: 'persisted',
|
|
2767
|
+
value: undefined,
|
|
2768
|
+
loc: node.loc
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2752
2773
|
};
|
|
2753
2774
|
}
|
|
2754
2775
|
}
|
|
@@ -2964,6 +2985,7 @@ function stringifyNode(node, context) {
|
|
|
2964
2985
|
}
|
|
2965
2986
|
function stringifyElement(node, context) {
|
|
2966
2987
|
let res = `<${node.tag}`;
|
|
2988
|
+
let innerHTML = '';
|
|
2967
2989
|
for (let i = 0; i < node.props.length; i++) {
|
|
2968
2990
|
const p = node.props[i];
|
|
2969
2991
|
if (p.type === 6 /* ATTRIBUTE */) {
|
|
@@ -2972,25 +2994,35 @@ function stringifyElement(node, context) {
|
|
|
2972
2994
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
2973
2995
|
}
|
|
2974
2996
|
}
|
|
2975
|
-
else if (p.type === 7 /* DIRECTIVE */
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
// constant v-bind, e.g. :foo="1"
|
|
2984
|
-
let evaluated = evaluateConstant(exp);
|
|
2985
|
-
if (evaluated != null) {
|
|
2986
|
-
const arg = p.arg && p.arg.content;
|
|
2987
|
-
if (arg === 'class') {
|
|
2988
|
-
evaluated = shared.normalizeClass(evaluated);
|
|
2997
|
+
else if (p.type === 7 /* DIRECTIVE */) {
|
|
2998
|
+
if (p.name === 'bind') {
|
|
2999
|
+
const exp = p.exp;
|
|
3000
|
+
if (exp.content[0] === '_') {
|
|
3001
|
+
// internally generated string constant references
|
|
3002
|
+
// e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
|
|
3003
|
+
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
3004
|
+
continue;
|
|
2989
3005
|
}
|
|
2990
|
-
|
|
2991
|
-
|
|
3006
|
+
// constant v-bind, e.g. :foo="1"
|
|
3007
|
+
let evaluated = evaluateConstant(exp);
|
|
3008
|
+
if (evaluated != null) {
|
|
3009
|
+
const arg = p.arg && p.arg.content;
|
|
3010
|
+
if (arg === 'class') {
|
|
3011
|
+
evaluated = shared.normalizeClass(evaluated);
|
|
3012
|
+
}
|
|
3013
|
+
else if (arg === 'style') {
|
|
3014
|
+
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
|
3015
|
+
}
|
|
3016
|
+
res += ` ${p.arg.content}="${shared.escapeHtml(evaluated)}"`;
|
|
2992
3017
|
}
|
|
2993
|
-
|
|
3018
|
+
}
|
|
3019
|
+
else if (p.name === 'html') {
|
|
3020
|
+
// #5439 v-html with constant value
|
|
3021
|
+
// not sure why would anyone do this but it can happen
|
|
3022
|
+
innerHTML = evaluateConstant(p.exp);
|
|
3023
|
+
}
|
|
3024
|
+
else if (p.name === 'text') {
|
|
3025
|
+
innerHTML = shared.escapeHtml(shared.toDisplayString(evaluateConstant(p.exp)));
|
|
2994
3026
|
}
|
|
2995
3027
|
}
|
|
2996
3028
|
}
|
|
@@ -2998,8 +3030,13 @@ function stringifyElement(node, context) {
|
|
|
2998
3030
|
res += ` ${context.scopeId}`;
|
|
2999
3031
|
}
|
|
3000
3032
|
res += `>`;
|
|
3001
|
-
|
|
3002
|
-
res +=
|
|
3033
|
+
if (innerHTML) {
|
|
3034
|
+
res += innerHTML;
|
|
3035
|
+
}
|
|
3036
|
+
else {
|
|
3037
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
3038
|
+
res += stringifyNode(node.children[i], context);
|
|
3039
|
+
}
|
|
3003
3040
|
}
|
|
3004
3041
|
if (!shared.isVoidTag(node.tag)) {
|
|
3005
3042
|
res += `</${node.tag}>`;
|
|
@@ -3012,7 +3049,7 @@ function stringifyElement(node, context) {
|
|
|
3012
3049
|
// here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
|
|
3013
3050
|
// in addition, constant exps bail on presence of parens so you can't even
|
|
3014
3051
|
// run JSFuck in here. But we mark it unsafe for security review purposes.
|
|
3015
|
-
// (see compiler-core/src/
|
|
3052
|
+
// (see compiler-core/src/transforms/transformExpression)
|
|
3016
3053
|
function evaluateConstant(exp) {
|
|
3017
3054
|
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
3018
3055
|
return new Function(`return ${exp.content}`)();
|
|
@@ -3049,7 +3086,7 @@ const ignoreSideEffectTags = (node, context) => {
|
|
|
3049
3086
|
|
|
3050
3087
|
const DOMNodeTransforms = [
|
|
3051
3088
|
transformStyle,
|
|
3052
|
-
...([
|
|
3089
|
+
...([transformTransition] )
|
|
3053
3090
|
];
|
|
3054
3091
|
const DOMDirectiveTransforms = {
|
|
3055
3092
|
cloak: compilerCore.noopDirectiveTransform,
|
|
@@ -2524,7 +2524,9 @@ const transformVText = (dir, node, context) => {
|
|
|
2524
2524
|
return {
|
|
2525
2525
|
props: [
|
|
2526
2526
|
compilerCore.createObjectProperty(compilerCore.createSimpleExpression(`textContent`, true), exp
|
|
2527
|
-
? compilerCore.
|
|
2527
|
+
? compilerCore.getConstantType(exp, context) > 0
|
|
2528
|
+
? exp
|
|
2529
|
+
: compilerCore.createCallExpression(context.helperString(compilerCore.TO_DISPLAY_STRING), [exp], loc)
|
|
2528
2530
|
: compilerCore.createSimpleExpression('', true))
|
|
2529
2531
|
]
|
|
2530
2532
|
};
|
|
@@ -2921,6 +2923,7 @@ function stringifyNode(node, context) {
|
|
|
2921
2923
|
}
|
|
2922
2924
|
function stringifyElement(node, context) {
|
|
2923
2925
|
let res = `<${node.tag}`;
|
|
2926
|
+
let innerHTML = '';
|
|
2924
2927
|
for (let i = 0; i < node.props.length; i++) {
|
|
2925
2928
|
const p = node.props[i];
|
|
2926
2929
|
if (p.type === 6 /* ATTRIBUTE */) {
|
|
@@ -2929,25 +2932,35 @@ function stringifyElement(node, context) {
|
|
|
2929
2932
|
res += `="${shared.escapeHtml(p.value.content)}"`;
|
|
2930
2933
|
}
|
|
2931
2934
|
}
|
|
2932
|
-
else if (p.type === 7 /* DIRECTIVE */
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
// constant v-bind, e.g. :foo="1"
|
|
2941
|
-
let evaluated = evaluateConstant(exp);
|
|
2942
|
-
if (evaluated != null) {
|
|
2943
|
-
const arg = p.arg && p.arg.content;
|
|
2944
|
-
if (arg === 'class') {
|
|
2945
|
-
evaluated = shared.normalizeClass(evaluated);
|
|
2935
|
+
else if (p.type === 7 /* DIRECTIVE */) {
|
|
2936
|
+
if (p.name === 'bind') {
|
|
2937
|
+
const exp = p.exp;
|
|
2938
|
+
if (exp.content[0] === '_') {
|
|
2939
|
+
// internally generated string constant references
|
|
2940
|
+
// e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
|
|
2941
|
+
res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
|
|
2942
|
+
continue;
|
|
2946
2943
|
}
|
|
2947
|
-
|
|
2948
|
-
|
|
2944
|
+
// constant v-bind, e.g. :foo="1"
|
|
2945
|
+
let evaluated = evaluateConstant(exp);
|
|
2946
|
+
if (evaluated != null) {
|
|
2947
|
+
const arg = p.arg && p.arg.content;
|
|
2948
|
+
if (arg === 'class') {
|
|
2949
|
+
evaluated = shared.normalizeClass(evaluated);
|
|
2950
|
+
}
|
|
2951
|
+
else if (arg === 'style') {
|
|
2952
|
+
evaluated = shared.stringifyStyle(shared.normalizeStyle(evaluated));
|
|
2953
|
+
}
|
|
2954
|
+
res += ` ${p.arg.content}="${shared.escapeHtml(evaluated)}"`;
|
|
2949
2955
|
}
|
|
2950
|
-
|
|
2956
|
+
}
|
|
2957
|
+
else if (p.name === 'html') {
|
|
2958
|
+
// #5439 v-html with constant value
|
|
2959
|
+
// not sure why would anyone do this but it can happen
|
|
2960
|
+
innerHTML = evaluateConstant(p.exp);
|
|
2961
|
+
}
|
|
2962
|
+
else if (p.name === 'text') {
|
|
2963
|
+
innerHTML = shared.escapeHtml(shared.toDisplayString(evaluateConstant(p.exp)));
|
|
2951
2964
|
}
|
|
2952
2965
|
}
|
|
2953
2966
|
}
|
|
@@ -2955,8 +2968,13 @@ function stringifyElement(node, context) {
|
|
|
2955
2968
|
res += ` ${context.scopeId}`;
|
|
2956
2969
|
}
|
|
2957
2970
|
res += `>`;
|
|
2958
|
-
|
|
2959
|
-
res +=
|
|
2971
|
+
if (innerHTML) {
|
|
2972
|
+
res += innerHTML;
|
|
2973
|
+
}
|
|
2974
|
+
else {
|
|
2975
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
2976
|
+
res += stringifyNode(node.children[i], context);
|
|
2977
|
+
}
|
|
2960
2978
|
}
|
|
2961
2979
|
if (!shared.isVoidTag(node.tag)) {
|
|
2962
2980
|
res += `</${node.tag}>`;
|
|
@@ -2969,7 +2987,7 @@ function stringifyElement(node, context) {
|
|
|
2969
2987
|
// here, e.g. `{{ 1 }}` or `{{ 'foo' }}`
|
|
2970
2988
|
// in addition, constant exps bail on presence of parens so you can't even
|
|
2971
2989
|
// run JSFuck in here. But we mark it unsafe for security review purposes.
|
|
2972
|
-
// (see compiler-core/src/
|
|
2990
|
+
// (see compiler-core/src/transforms/transformExpression)
|
|
2973
2991
|
function evaluateConstant(exp) {
|
|
2974
2992
|
if (exp.type === 4 /* SIMPLE_EXPRESSION */) {
|
|
2975
2993
|
return new Function(`return ${exp.content}`)();
|
|
@@ -2371,6 +2371,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2371
2371
|
}
|
|
2372
2372
|
|
|
2373
2373
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2374
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2374
2375
|
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2375
2376
|
const context = {
|
|
2376
2377
|
mode,
|
|
@@ -2447,9 +2448,7 @@ function generate(ast, options = {}) {
|
|
|
2447
2448
|
// function mode const declarations should be inside with block
|
|
2448
2449
|
// also they should be renamed to avoid collision with user properties
|
|
2449
2450
|
if (hasHelpers) {
|
|
2450
|
-
push(`const { ${ast.helpers
|
|
2451
|
-
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
|
2452
|
-
.join(', ')} } = _Vue`);
|
|
2451
|
+
push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
|
|
2453
2452
|
push(`\n`);
|
|
2454
2453
|
newline();
|
|
2455
2454
|
}
|
|
@@ -2509,7 +2508,6 @@ function generate(ast, options = {}) {
|
|
|
2509
2508
|
function genFunctionPreamble(ast, context) {
|
|
2510
2509
|
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2511
2510
|
const VueBinding = runtimeGlobalName;
|
|
2512
|
-
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2513
2511
|
// Generate const declaration for helpers
|
|
2514
2512
|
// In prefix mode, we place the const declaration at top so it's done
|
|
2515
2513
|
// only once; But if we not prefixing, we place the declaration inside the
|
|
@@ -3224,14 +3222,14 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3224
3222
|
}
|
|
3225
3223
|
}
|
|
3226
3224
|
function createIfBranch(node, dir) {
|
|
3225
|
+
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3227
3226
|
return {
|
|
3228
3227
|
type: 10 /* IF_BRANCH */,
|
|
3229
3228
|
loc: node.loc,
|
|
3230
3229
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3231
|
-
children:
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
userKey: findProp(node, `key`)
|
|
3230
|
+
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
3231
|
+
userKey: findProp(node, `key`),
|
|
3232
|
+
isTemplateIf
|
|
3235
3233
|
};
|
|
3236
3234
|
}
|
|
3237
3235
|
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
@@ -3266,7 +3264,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3266
3264
|
let patchFlagText = PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
3267
3265
|
// check if the fragment actually contains a single valid child with
|
|
3268
3266
|
// the rest being comments
|
|
3269
|
-
if (
|
|
3267
|
+
if (!branch.isTemplateIf &&
|
|
3268
|
+
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3270
3269
|
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3271
3270
|
patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
3272
3271
|
}
|
|
@@ -3842,7 +3841,7 @@ const transformElement = (node, context) => {
|
|
|
3842
3841
|
(tag === 'svg' || tag === 'foreignObject'));
|
|
3843
3842
|
// props
|
|
3844
3843
|
if (props.length > 0) {
|
|
3845
|
-
const propsBuildResult = buildProps(node, context);
|
|
3844
|
+
const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
|
|
3846
3845
|
vnodeProps = propsBuildResult.props;
|
|
3847
3846
|
patchFlag = propsBuildResult.patchFlag;
|
|
3848
3847
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
@@ -3981,9 +3980,8 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3981
3980
|
context.components.add(tag);
|
|
3982
3981
|
return toValidAssetId(tag, `component`);
|
|
3983
3982
|
}
|
|
3984
|
-
function buildProps(node, context, props = node.props, ssr = false) {
|
|
3983
|
+
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
3985
3984
|
const { tag, loc: elementLoc, children } = node;
|
|
3986
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
3987
3985
|
let properties = [];
|
|
3988
3986
|
const mergeArgs = [];
|
|
3989
3987
|
const runtimeDirectives = [];
|
|
@@ -4002,8 +4000,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4002
4000
|
if (isStaticExp(key)) {
|
|
4003
4001
|
const name = key.content;
|
|
4004
4002
|
const isEventHandler = isOn(name);
|
|
4005
|
-
if (
|
|
4006
|
-
|
|
4003
|
+
if (isEventHandler &&
|
|
4004
|
+
(!isComponent || isDynamicComponent) &&
|
|
4007
4005
|
// omit the flag for click handlers because hydration gives click
|
|
4008
4006
|
// dedicated fast path.
|
|
4009
4007
|
name.toLowerCase() !== 'onclick' &&
|
|
@@ -4258,10 +4256,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4258
4256
|
classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4259
4257
|
}
|
|
4260
4258
|
if (styleProp &&
|
|
4261
|
-
!isStaticExp(styleProp.value) &&
|
|
4262
4259
|
// the static style is compiled into an object,
|
|
4263
4260
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4264
4261
|
(hasStyleBinding ||
|
|
4262
|
+
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4263
|
+
styleProp.value.content.trim()[0] === `[`) ||
|
|
4265
4264
|
// v-bind:style and style both exist,
|
|
4266
4265
|
// v-bind:style with static literal object
|
|
4267
4266
|
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
@@ -4440,7 +4439,7 @@ function processSlotOutlet(node, context) {
|
|
|
4440
4439
|
}
|
|
4441
4440
|
}
|
|
4442
4441
|
if (nonNameProps.length > 0) {
|
|
4443
|
-
const { props, directives } = buildProps(node, context, nonNameProps);
|
|
4442
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4444
4443
|
slotProps = props;
|
|
4445
4444
|
if (directives.length) {
|
|
4446
4445
|
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
@@ -4611,11 +4610,7 @@ const transformText = (node, context) => {
|
|
|
4611
4610
|
const next = children[j];
|
|
4612
4611
|
if (isText(next)) {
|
|
4613
4612
|
if (!currentContainer) {
|
|
4614
|
-
currentContainer = children[i] =
|
|
4615
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
4616
|
-
loc: child.loc,
|
|
4617
|
-
children: [child]
|
|
4618
|
-
};
|
|
4613
|
+
currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
4619
4614
|
}
|
|
4620
4615
|
// merge adjacent text node into current
|
|
4621
4616
|
currentContainer.children.push(` + `, next);
|
|
@@ -5187,7 +5182,9 @@ const transformVText = (dir, node, context) => {
|
|
|
5187
5182
|
return {
|
|
5188
5183
|
props: [
|
|
5189
5184
|
createObjectProperty(createSimpleExpression(`textContent`, true), exp
|
|
5190
|
-
?
|
|
5185
|
+
? getConstantType(exp, context) > 0
|
|
5186
|
+
? exp
|
|
5187
|
+
: createCallExpression(context.helperString(TO_DISPLAY_STRING), [exp], loc)
|
|
5191
5188
|
: createSimpleExpression('', true))
|
|
5192
5189
|
]
|
|
5193
5190
|
};
|
|
@@ -5399,19 +5396,38 @@ const transformShow = (dir, node, context) => {
|
|
|
5399
5396
|
};
|
|
5400
5397
|
};
|
|
5401
5398
|
|
|
5402
|
-
const
|
|
5399
|
+
const transformTransition = (node, context) => {
|
|
5403
5400
|
if (node.type === 1 /* ELEMENT */ &&
|
|
5404
5401
|
node.tagType === 1 /* COMPONENT */) {
|
|
5405
5402
|
const component = context.isBuiltInComponent(node.tag);
|
|
5406
5403
|
if (component === TRANSITION) {
|
|
5407
5404
|
return () => {
|
|
5408
|
-
if (node.children.length
|
|
5405
|
+
if (!node.children.length) {
|
|
5406
|
+
return;
|
|
5407
|
+
}
|
|
5408
|
+
// warn multiple transition children
|
|
5409
|
+
if (hasMultipleChildren(node)) {
|
|
5409
5410
|
context.onError(createDOMCompilerError(59 /* X_TRANSITION_INVALID_CHILDREN */, {
|
|
5410
5411
|
start: node.children[0].loc.start,
|
|
5411
5412
|
end: node.children[node.children.length - 1].loc.end,
|
|
5412
5413
|
source: ''
|
|
5413
5414
|
}));
|
|
5414
5415
|
}
|
|
5416
|
+
// check if it's s single child w/ v-show
|
|
5417
|
+
// if yes, inject "persisted: true" to the transition props
|
|
5418
|
+
const child = node.children[0];
|
|
5419
|
+
if (child.type === 1 /* ELEMENT */) {
|
|
5420
|
+
for (const p of child.props) {
|
|
5421
|
+
if (p.type === 7 /* DIRECTIVE */ && p.name === 'show') {
|
|
5422
|
+
node.props.push({
|
|
5423
|
+
type: 6 /* ATTRIBUTE */,
|
|
5424
|
+
name: 'persisted',
|
|
5425
|
+
value: undefined,
|
|
5426
|
+
loc: node.loc
|
|
5427
|
+
});
|
|
5428
|
+
}
|
|
5429
|
+
}
|
|
5430
|
+
}
|
|
5415
5431
|
};
|
|
5416
5432
|
}
|
|
5417
5433
|
}
|
|
@@ -5437,7 +5453,7 @@ const ignoreSideEffectTags = (node, context) => {
|
|
|
5437
5453
|
|
|
5438
5454
|
const DOMNodeTransforms = [
|
|
5439
5455
|
transformStyle,
|
|
5440
|
-
...([
|
|
5456
|
+
...([transformTransition] )
|
|
5441
5457
|
];
|
|
5442
5458
|
const DOMDirectiveTransforms = {
|
|
5443
5459
|
cloak: noopDirectiveTransform,
|
|
@@ -5465,4 +5481,4 @@ function parse(template, options = {}) {
|
|
|
5465
5481
|
return baseParse(template, extend({}, parserOptions, options));
|
|
5466
5482
|
}
|
|
5467
5483
|
|
|
5468
|
-
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, DOMDirectiveTransforms, DOMNodeTransforms, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, generateCodeFrame, getBaseTransformPreset, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText, isVSlot, locStub, makeBlock, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformStyle, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
|
5484
|
+
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, DOMDirectiveTransforms, DOMNodeTransforms, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TRANSITION, TRANSITION_GROUP, UNREF, V_MODEL_CHECKBOX, V_MODEL_DYNAMIC, V_MODEL_RADIO, V_MODEL_SELECT, V_MODEL_TEXT, V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS, V_SHOW, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, compile, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createDOMCompilerError, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, generateCodeFrame, getBaseTransformPreset, getConstantType, getInnerRange, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isBuiltInType, isCoreComponent, isFunctionType, isInDestructureAssignment, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText, isVSlot, locStub, makeBlock, noopDirectiveTransform, parse, parserOptions, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, transformStyle, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|