@vue/compiler-core 3.2.32 → 3.2.34
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.
|
@@ -2235,6 +2235,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2235
2235
|
}
|
|
2236
2236
|
|
|
2237
2237
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2238
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2238
2239
|
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2239
2240
|
const context = {
|
|
2240
2241
|
mode,
|
|
@@ -2362,9 +2363,7 @@ function generate(ast, options = {}) {
|
|
|
2362
2363
|
// function mode const declarations should be inside with block
|
|
2363
2364
|
// also they should be renamed to avoid collision with user properties
|
|
2364
2365
|
if (hasHelpers) {
|
|
2365
|
-
push(`const { ${ast.helpers
|
|
2366
|
-
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
|
2367
|
-
.join(', ')} } = _Vue`);
|
|
2366
|
+
push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
|
|
2368
2367
|
push(`\n`);
|
|
2369
2368
|
newline();
|
|
2370
2369
|
}
|
|
@@ -2426,7 +2425,6 @@ function genFunctionPreamble(ast, context) {
|
|
|
2426
2425
|
const VueBinding = ssr
|
|
2427
2426
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
|
2428
2427
|
: runtimeGlobalName;
|
|
2429
|
-
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2430
2428
|
// Generate const declaration for helpers
|
|
2431
2429
|
// In prefix mode, we place the const declaration at top so it's done
|
|
2432
2430
|
// only once; But if we not prefixing, we place the declaration inside the
|
|
@@ -3260,7 +3258,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
3260
3258
|
// no: export { NODE as foo } from "foo";
|
|
3261
3259
|
case 'ExportSpecifier':
|
|
3262
3260
|
// @ts-expect-error
|
|
3263
|
-
if (grandparent
|
|
3261
|
+
if (grandparent?.source) {
|
|
3264
3262
|
return false;
|
|
3265
3263
|
}
|
|
3266
3264
|
return parent.local === node;
|
|
@@ -3358,7 +3356,9 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3358
3356
|
const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
|
|
3359
3357
|
// ({ x } = y)
|
|
3360
3358
|
const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
|
|
3361
|
-
if (type === "setup-const" /* SETUP_CONST */ ||
|
|
3359
|
+
if (type === "setup-const" /* SETUP_CONST */ ||
|
|
3360
|
+
type === "setup-reactive-const" /* SETUP_REACTIVE_CONST */ ||
|
|
3361
|
+
localVars[raw]) {
|
|
3362
3362
|
return raw;
|
|
3363
3363
|
}
|
|
3364
3364
|
else if (type === "setup-ref" /* SETUP_REF */) {
|
|
@@ -3412,11 +3412,11 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3412
3412
|
else if (type === "props" /* PROPS */) {
|
|
3413
3413
|
// use __props which is generated by compileScript so in ts mode
|
|
3414
3414
|
// it gets correct type
|
|
3415
|
-
return
|
|
3415
|
+
return shared.genPropsAccessExp(raw);
|
|
3416
3416
|
}
|
|
3417
3417
|
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3418
3418
|
// prop with a different local alias (from defineProps() destructure)
|
|
3419
|
-
return
|
|
3419
|
+
return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
|
|
3420
3420
|
}
|
|
3421
3421
|
}
|
|
3422
3422
|
else {
|
|
@@ -3425,7 +3425,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3425
3425
|
return `$setup.${raw}`;
|
|
3426
3426
|
}
|
|
3427
3427
|
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3428
|
-
return `$props
|
|
3428
|
+
return `$props['${bindingMetadata.__propsAliases[raw]}']`;
|
|
3429
3429
|
}
|
|
3430
3430
|
else if (type) {
|
|
3431
3431
|
return `$${type}.${raw}`;
|
|
@@ -3690,14 +3690,14 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3690
3690
|
}
|
|
3691
3691
|
}
|
|
3692
3692
|
function createIfBranch(node, dir) {
|
|
3693
|
+
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3693
3694
|
return {
|
|
3694
3695
|
type: 10 /* IF_BRANCH */,
|
|
3695
3696
|
loc: node.loc,
|
|
3696
3697
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3697
|
-
children:
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
userKey: findProp(node, `key`)
|
|
3698
|
+
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
3699
|
+
userKey: findProp(node, `key`),
|
|
3700
|
+
isTemplateIf
|
|
3701
3701
|
};
|
|
3702
3702
|
}
|
|
3703
3703
|
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
@@ -3732,7 +3732,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3732
3732
|
let patchFlagText = shared.PatchFlagNames[64 /* STABLE_FRAGMENT */];
|
|
3733
3733
|
// check if the fragment actually contains a single valid child with
|
|
3734
3734
|
// the rest being comments
|
|
3735
|
-
if (
|
|
3735
|
+
if (!branch.isTemplateIf &&
|
|
3736
|
+
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3736
3737
|
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3737
3738
|
patchFlagText += `, ${shared.PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
3738
3739
|
}
|
|
@@ -4343,7 +4344,7 @@ const transformElement = (node, context) => {
|
|
|
4343
4344
|
(tag === 'svg' || tag === 'foreignObject'));
|
|
4344
4345
|
// props
|
|
4345
4346
|
if (props.length > 0) {
|
|
4346
|
-
const propsBuildResult = buildProps(node, context);
|
|
4347
|
+
const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
|
|
4347
4348
|
vnodeProps = propsBuildResult.props;
|
|
4348
4349
|
patchFlag = propsBuildResult.patchFlag;
|
|
4349
4350
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
@@ -4526,7 +4527,8 @@ function resolveSetupReference(name, context) {
|
|
|
4526
4527
|
return PascalName;
|
|
4527
4528
|
}
|
|
4528
4529
|
};
|
|
4529
|
-
const fromConst = checkType("setup-const" /* SETUP_CONST */)
|
|
4530
|
+
const fromConst = checkType("setup-const" /* SETUP_CONST */) ||
|
|
4531
|
+
checkType("setup-reactive-const" /* SETUP_REACTIVE_CONST */);
|
|
4530
4532
|
if (fromConst) {
|
|
4531
4533
|
return context.inline
|
|
4532
4534
|
? // in inline mode, const setup bindings (e.g. imports) can be used as-is
|
|
@@ -4543,9 +4545,8 @@ function resolveSetupReference(name, context) {
|
|
|
4543
4545
|
: `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
4544
4546
|
}
|
|
4545
4547
|
}
|
|
4546
|
-
function buildProps(node, context, props = node.props, ssr = false) {
|
|
4548
|
+
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
4547
4549
|
const { tag, loc: elementLoc, children } = node;
|
|
4548
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
4549
4550
|
let properties = [];
|
|
4550
4551
|
const mergeArgs = [];
|
|
4551
4552
|
const runtimeDirectives = [];
|
|
@@ -4564,8 +4565,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4564
4565
|
if (isStaticExp(key)) {
|
|
4565
4566
|
const name = key.content;
|
|
4566
4567
|
const isEventHandler = shared.isOn(name);
|
|
4567
|
-
if (
|
|
4568
|
-
|
|
4568
|
+
if (isEventHandler &&
|
|
4569
|
+
(!isComponent || isDynamicComponent) &&
|
|
4569
4570
|
// omit the flag for click handlers because hydration gives click
|
|
4570
4571
|
// dedicated fast path.
|
|
4571
4572
|
name.toLowerCase() !== 'onclick' &&
|
|
@@ -4829,10 +4830,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4829
4830
|
classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4830
4831
|
}
|
|
4831
4832
|
if (styleProp &&
|
|
4832
|
-
!isStaticExp(styleProp.value) &&
|
|
4833
4833
|
// the static style is compiled into an object,
|
|
4834
4834
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4835
4835
|
(hasStyleBinding ||
|
|
4836
|
+
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4837
|
+
styleProp.value.content.trim()[0] === `[`) ||
|
|
4836
4838
|
// v-bind:style and style both exist,
|
|
4837
4839
|
// v-bind:style with static literal object
|
|
4838
4840
|
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
@@ -5035,7 +5037,7 @@ function processSlotOutlet(node, context) {
|
|
|
5035
5037
|
}
|
|
5036
5038
|
}
|
|
5037
5039
|
if (nonNameProps.length > 0) {
|
|
5038
|
-
const { props, directives } = buildProps(node, context, nonNameProps);
|
|
5040
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
5039
5041
|
slotProps = props;
|
|
5040
5042
|
if (directives.length) {
|
|
5041
5043
|
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
@@ -5241,11 +5243,7 @@ const transformText = (node, context) => {
|
|
|
5241
5243
|
const next = children[j];
|
|
5242
5244
|
if (isText(next)) {
|
|
5243
5245
|
if (!currentContainer) {
|
|
5244
|
-
currentContainer = children[i] =
|
|
5245
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
5246
|
-
loc: child.loc,
|
|
5247
|
-
children: [child]
|
|
5248
|
-
};
|
|
5246
|
+
currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
5249
5247
|
}
|
|
5250
5248
|
// merge adjacent text node into current
|
|
5251
5249
|
currentContainer.children.push(` + `, next);
|
|
@@ -5751,6 +5749,7 @@ exports.findDir = findDir;
|
|
|
5751
5749
|
exports.findProp = findProp;
|
|
5752
5750
|
exports.generate = generate;
|
|
5753
5751
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
5752
|
+
exports.getConstantType = getConstantType;
|
|
5754
5753
|
exports.getInnerRange = getInnerRange;
|
|
5755
5754
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
5756
5755
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
@@ -2185,6 +2185,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2185
2185
|
}
|
|
2186
2186
|
|
|
2187
2187
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2188
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2188
2189
|
function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
|
|
2189
2190
|
const context = {
|
|
2190
2191
|
mode,
|
|
@@ -2312,9 +2313,7 @@ function generate(ast, options = {}) {
|
|
|
2312
2313
|
// function mode const declarations should be inside with block
|
|
2313
2314
|
// also they should be renamed to avoid collision with user properties
|
|
2314
2315
|
if (hasHelpers) {
|
|
2315
|
-
push(`const { ${ast.helpers
|
|
2316
|
-
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
|
2317
|
-
.join(', ')} } = _Vue`);
|
|
2316
|
+
push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
|
|
2318
2317
|
push(`\n`);
|
|
2319
2318
|
newline();
|
|
2320
2319
|
}
|
|
@@ -2376,7 +2375,6 @@ function genFunctionPreamble(ast, context) {
|
|
|
2376
2375
|
const VueBinding = ssr
|
|
2377
2376
|
? `require(${JSON.stringify(runtimeModuleName)})`
|
|
2378
2377
|
: runtimeGlobalName;
|
|
2379
|
-
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2380
2378
|
// Generate const declaration for helpers
|
|
2381
2379
|
// In prefix mode, we place the const declaration at top so it's done
|
|
2382
2380
|
// only once; But if we not prefixing, we place the declaration inside the
|
|
@@ -3197,7 +3195,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
3197
3195
|
// no: export { NODE as foo } from "foo";
|
|
3198
3196
|
case 'ExportSpecifier':
|
|
3199
3197
|
// @ts-expect-error
|
|
3200
|
-
if (grandparent
|
|
3198
|
+
if (grandparent?.source) {
|
|
3201
3199
|
return false;
|
|
3202
3200
|
}
|
|
3203
3201
|
return parent.local === node;
|
|
@@ -3295,7 +3293,9 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3295
3293
|
const isUpdateArg = parent && parent.type === 'UpdateExpression' && parent.argument === id;
|
|
3296
3294
|
// ({ x } = y)
|
|
3297
3295
|
const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
|
|
3298
|
-
if (type === "setup-const" /* SETUP_CONST */ ||
|
|
3296
|
+
if (type === "setup-const" /* SETUP_CONST */ ||
|
|
3297
|
+
type === "setup-reactive-const" /* SETUP_REACTIVE_CONST */ ||
|
|
3298
|
+
localVars[raw]) {
|
|
3299
3299
|
return raw;
|
|
3300
3300
|
}
|
|
3301
3301
|
else if (type === "setup-ref" /* SETUP_REF */) {
|
|
@@ -3349,11 +3349,11 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3349
3349
|
else if (type === "props" /* PROPS */) {
|
|
3350
3350
|
// use __props which is generated by compileScript so in ts mode
|
|
3351
3351
|
// it gets correct type
|
|
3352
|
-
return
|
|
3352
|
+
return shared.genPropsAccessExp(raw);
|
|
3353
3353
|
}
|
|
3354
3354
|
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3355
3355
|
// prop with a different local alias (from defineProps() destructure)
|
|
3356
|
-
return
|
|
3356
|
+
return shared.genPropsAccessExp(bindingMetadata.__propsAliases[raw]);
|
|
3357
3357
|
}
|
|
3358
3358
|
}
|
|
3359
3359
|
else {
|
|
@@ -3362,7 +3362,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
|
|
|
3362
3362
|
return `$setup.${raw}`;
|
|
3363
3363
|
}
|
|
3364
3364
|
else if (type === "props-aliased" /* PROPS_ALIASED */) {
|
|
3365
|
-
return `$props
|
|
3365
|
+
return `$props['${bindingMetadata.__propsAliases[raw]}']`;
|
|
3366
3366
|
}
|
|
3367
3367
|
else if (type) {
|
|
3368
3368
|
return `$${type}.${raw}`;
|
|
@@ -3614,14 +3614,14 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3614
3614
|
}
|
|
3615
3615
|
}
|
|
3616
3616
|
function createIfBranch(node, dir) {
|
|
3617
|
+
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3617
3618
|
return {
|
|
3618
3619
|
type: 10 /* IF_BRANCH */,
|
|
3619
3620
|
loc: node.loc,
|
|
3620
3621
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3621
|
-
children:
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
userKey: findProp(node, `key`)
|
|
3622
|
+
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
3623
|
+
userKey: findProp(node, `key`),
|
|
3624
|
+
isTemplateIf
|
|
3625
3625
|
};
|
|
3626
3626
|
}
|
|
3627
3627
|
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
@@ -4260,7 +4260,7 @@ const transformElement = (node, context) => {
|
|
|
4260
4260
|
(tag === 'svg' || tag === 'foreignObject'));
|
|
4261
4261
|
// props
|
|
4262
4262
|
if (props.length > 0) {
|
|
4263
|
-
const propsBuildResult = buildProps(node, context);
|
|
4263
|
+
const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
|
|
4264
4264
|
vnodeProps = propsBuildResult.props;
|
|
4265
4265
|
patchFlag = propsBuildResult.patchFlag;
|
|
4266
4266
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
@@ -4424,7 +4424,8 @@ function resolveSetupReference(name, context) {
|
|
|
4424
4424
|
return PascalName;
|
|
4425
4425
|
}
|
|
4426
4426
|
};
|
|
4427
|
-
const fromConst = checkType("setup-const" /* SETUP_CONST */)
|
|
4427
|
+
const fromConst = checkType("setup-const" /* SETUP_CONST */) ||
|
|
4428
|
+
checkType("setup-reactive-const" /* SETUP_REACTIVE_CONST */);
|
|
4428
4429
|
if (fromConst) {
|
|
4429
4430
|
return context.inline
|
|
4430
4431
|
? // in inline mode, const setup bindings (e.g. imports) can be used as-is
|
|
@@ -4441,9 +4442,8 @@ function resolveSetupReference(name, context) {
|
|
|
4441
4442
|
: `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
4442
4443
|
}
|
|
4443
4444
|
}
|
|
4444
|
-
function buildProps(node, context, props = node.props, ssr = false) {
|
|
4445
|
+
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
4445
4446
|
const { tag, loc: elementLoc, children } = node;
|
|
4446
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
4447
4447
|
let properties = [];
|
|
4448
4448
|
const mergeArgs = [];
|
|
4449
4449
|
const runtimeDirectives = [];
|
|
@@ -4462,8 +4462,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4462
4462
|
if (isStaticExp(key)) {
|
|
4463
4463
|
const name = key.content;
|
|
4464
4464
|
const isEventHandler = shared.isOn(name);
|
|
4465
|
-
if (
|
|
4466
|
-
|
|
4465
|
+
if (isEventHandler &&
|
|
4466
|
+
(!isComponent || isDynamicComponent) &&
|
|
4467
4467
|
// omit the flag for click handlers because hydration gives click
|
|
4468
4468
|
// dedicated fast path.
|
|
4469
4469
|
name.toLowerCase() !== 'onclick' &&
|
|
@@ -4704,10 +4704,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4704
4704
|
classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4705
4705
|
}
|
|
4706
4706
|
if (styleProp &&
|
|
4707
|
-
!isStaticExp(styleProp.value) &&
|
|
4708
4707
|
// the static style is compiled into an object,
|
|
4709
4708
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4710
4709
|
(hasStyleBinding ||
|
|
4710
|
+
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4711
|
+
styleProp.value.content.trim()[0] === `[`) ||
|
|
4711
4712
|
// v-bind:style and style both exist,
|
|
4712
4713
|
// v-bind:style with static literal object
|
|
4713
4714
|
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
@@ -4907,7 +4908,7 @@ function processSlotOutlet(node, context) {
|
|
|
4907
4908
|
}
|
|
4908
4909
|
}
|
|
4909
4910
|
if (nonNameProps.length > 0) {
|
|
4910
|
-
const { props, directives } = buildProps(node, context, nonNameProps);
|
|
4911
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4911
4912
|
slotProps = props;
|
|
4912
4913
|
if (directives.length) {
|
|
4913
4914
|
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
@@ -5113,11 +5114,7 @@ const transformText = (node, context) => {
|
|
|
5113
5114
|
const next = children[j];
|
|
5114
5115
|
if (isText(next)) {
|
|
5115
5116
|
if (!currentContainer) {
|
|
5116
|
-
currentContainer = children[i] =
|
|
5117
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
5118
|
-
loc: child.loc,
|
|
5119
|
-
children: [child]
|
|
5120
|
-
};
|
|
5117
|
+
currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
5121
5118
|
}
|
|
5122
5119
|
// merge adjacent text node into current
|
|
5123
5120
|
currentContainer.children.push(` + `, next);
|
|
@@ -5622,6 +5619,7 @@ exports.findDir = findDir;
|
|
|
5622
5619
|
exports.findProp = findProp;
|
|
5623
5620
|
exports.generate = generate;
|
|
5624
5621
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
5622
|
+
exports.getConstantType = getConstantType;
|
|
5625
5623
|
exports.getInnerRange = getInnerRange;
|
|
5626
5624
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
5627
5625
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -79,6 +79,10 @@ export declare const enum BindingTypes {
|
|
|
79
79
|
* template expressions.
|
|
80
80
|
*/
|
|
81
81
|
SETUP_CONST = "setup-const",
|
|
82
|
+
/**
|
|
83
|
+
* a const binding that does not need `unref()`, but may be mutated.
|
|
84
|
+
*/
|
|
85
|
+
SETUP_REACTIVE_CONST = "setup-reactive-const",
|
|
82
86
|
/**
|
|
83
87
|
* a const binding that may be a ref.
|
|
84
88
|
*/
|
|
@@ -102,7 +106,7 @@ export declare interface BlockStatement extends Node_2 {
|
|
|
102
106
|
|
|
103
107
|
export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
|
|
104
108
|
|
|
105
|
-
export declare function buildProps(node: ElementNode, context: TransformContext, props
|
|
109
|
+
export declare function buildProps(node: ElementNode, context: TransformContext, props: (DirectiveNode | AttributeNode)[] | undefined, isComponent: boolean, isDynamicComponent: boolean, ssr?: boolean): {
|
|
106
110
|
props: PropsExpression | undefined;
|
|
107
111
|
directives: DirectiveNode[];
|
|
108
112
|
patchFlag: number;
|
|
@@ -528,6 +532,8 @@ export { generateCodeFrame }
|
|
|
528
532
|
|
|
529
533
|
export declare function getBaseTransformPreset(prefixIdentifiers?: boolean): TransformPreset;
|
|
530
534
|
|
|
535
|
+
export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode, context: TransformContext): ConstantTypes;
|
|
536
|
+
|
|
531
537
|
export declare function getInnerRange(loc: SourceLocation, offset: number, length: number): SourceLocation;
|
|
532
538
|
|
|
533
539
|
export declare function getMemoedVNodeCall(node: BlockCodegenNode | MemoExpression): VNodeCall | RenderSlotCall;
|
|
@@ -551,6 +557,7 @@ export declare interface IfBranchNode extends Node_2 {
|
|
|
551
557
|
condition: ExpressionNode | undefined;
|
|
552
558
|
children: TemplateChildNode[];
|
|
553
559
|
userKey?: AttributeNode | DirectiveNode;
|
|
560
|
+
isTemplateIf?: boolean;
|
|
554
561
|
}
|
|
555
562
|
|
|
556
563
|
export declare interface IfConditionalExpression extends ConditionalExpression {
|
|
@@ -2189,6 +2189,7 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
2189
2189
|
}
|
|
2190
2190
|
|
|
2191
2191
|
const PURE_ANNOTATION = `/*#__PURE__*/`;
|
|
2192
|
+
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2192
2193
|
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 }) {
|
|
2193
2194
|
const context = {
|
|
2194
2195
|
mode,
|
|
@@ -2265,9 +2266,7 @@ function generate(ast, options = {}) {
|
|
|
2265
2266
|
// function mode const declarations should be inside with block
|
|
2266
2267
|
// also they should be renamed to avoid collision with user properties
|
|
2267
2268
|
if (hasHelpers) {
|
|
2268
|
-
push(`const { ${ast.helpers
|
|
2269
|
-
.map(s => `${helperNameMap[s]}: _${helperNameMap[s]}`)
|
|
2270
|
-
.join(', ')} } = _Vue`);
|
|
2269
|
+
push(`const { ${ast.helpers.map(aliasHelper).join(', ')} } = _Vue`);
|
|
2271
2270
|
push(`\n`);
|
|
2272
2271
|
newline();
|
|
2273
2272
|
}
|
|
@@ -2327,7 +2326,6 @@ function generate(ast, options = {}) {
|
|
|
2327
2326
|
function genFunctionPreamble(ast, context) {
|
|
2328
2327
|
const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
|
|
2329
2328
|
const VueBinding = runtimeGlobalName;
|
|
2330
|
-
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
2331
2329
|
// Generate const declaration for helpers
|
|
2332
2330
|
// In prefix mode, we place the const declaration at top so it's done
|
|
2333
2331
|
// only once; But if we not prefixing, we place the declaration inside the
|
|
@@ -3045,14 +3043,14 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3045
3043
|
}
|
|
3046
3044
|
}
|
|
3047
3045
|
function createIfBranch(node, dir) {
|
|
3046
|
+
const isTemplateIf = node.tagType === 3 /* TEMPLATE */;
|
|
3048
3047
|
return {
|
|
3049
3048
|
type: 10 /* IF_BRANCH */,
|
|
3050
3049
|
loc: node.loc,
|
|
3051
3050
|
condition: dir.name === 'else' ? undefined : dir.exp,
|
|
3052
|
-
children:
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
userKey: findProp(node, `key`)
|
|
3051
|
+
children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
|
|
3052
|
+
userKey: findProp(node, `key`),
|
|
3053
|
+
isTemplateIf
|
|
3056
3054
|
};
|
|
3057
3055
|
}
|
|
3058
3056
|
function createCodegenNodeForBranch(branch, keyIndex, context) {
|
|
@@ -3088,6 +3086,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3088
3086
|
// check if the fragment actually contains a single valid child with
|
|
3089
3087
|
// the rest being comments
|
|
3090
3088
|
if ((process.env.NODE_ENV !== 'production') &&
|
|
3089
|
+
!branch.isTemplateIf &&
|
|
3091
3090
|
children.filter(c => c.type !== 3 /* COMMENT */).length === 1) {
|
|
3092
3091
|
patchFlag |= 2048 /* DEV_ROOT_FRAGMENT */;
|
|
3093
3092
|
patchFlagText += `, ${PatchFlagNames[2048 /* DEV_ROOT_FRAGMENT */]}`;
|
|
@@ -3665,7 +3664,7 @@ const transformElement = (node, context) => {
|
|
|
3665
3664
|
(tag === 'svg' || tag === 'foreignObject'));
|
|
3666
3665
|
// props
|
|
3667
3666
|
if (props.length > 0) {
|
|
3668
|
-
const propsBuildResult = buildProps(node, context);
|
|
3667
|
+
const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
|
|
3669
3668
|
vnodeProps = propsBuildResult.props;
|
|
3670
3669
|
patchFlag = propsBuildResult.patchFlag;
|
|
3671
3670
|
dynamicPropNames = propsBuildResult.dynamicPropNames;
|
|
@@ -3807,9 +3806,8 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
3807
3806
|
context.components.add(tag);
|
|
3808
3807
|
return toValidAssetId(tag, `component`);
|
|
3809
3808
|
}
|
|
3810
|
-
function buildProps(node, context, props = node.props, ssr = false) {
|
|
3809
|
+
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
3811
3810
|
const { tag, loc: elementLoc, children } = node;
|
|
3812
|
-
const isComponent = node.tagType === 1 /* COMPONENT */;
|
|
3813
3811
|
let properties = [];
|
|
3814
3812
|
const mergeArgs = [];
|
|
3815
3813
|
const runtimeDirectives = [];
|
|
@@ -3828,8 +3826,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
3828
3826
|
if (isStaticExp(key)) {
|
|
3829
3827
|
const name = key.content;
|
|
3830
3828
|
const isEventHandler = isOn(name);
|
|
3831
|
-
if (
|
|
3832
|
-
|
|
3829
|
+
if (isEventHandler &&
|
|
3830
|
+
(!isComponent || isDynamicComponent) &&
|
|
3833
3831
|
// omit the flag for click handlers because hydration gives click
|
|
3834
3832
|
// dedicated fast path.
|
|
3835
3833
|
name.toLowerCase() !== 'onclick' &&
|
|
@@ -4084,10 +4082,11 @@ function buildProps(node, context, props = node.props, ssr = false) {
|
|
|
4084
4082
|
classProp.value = createCallExpression(context.helper(NORMALIZE_CLASS), [classProp.value]);
|
|
4085
4083
|
}
|
|
4086
4084
|
if (styleProp &&
|
|
4087
|
-
!isStaticExp(styleProp.value) &&
|
|
4088
4085
|
// the static style is compiled into an object,
|
|
4089
4086
|
// so use `hasStyleBinding` to ensure that it is a dynamic style binding
|
|
4090
4087
|
(hasStyleBinding ||
|
|
4088
|
+
(styleProp.value.type === 4 /* SIMPLE_EXPRESSION */ &&
|
|
4089
|
+
styleProp.value.content.trim()[0] === `[`) ||
|
|
4091
4090
|
// v-bind:style and style both exist,
|
|
4092
4091
|
// v-bind:style with static literal object
|
|
4093
4092
|
styleProp.value.type === 17 /* JS_ARRAY_EXPRESSION */)) {
|
|
@@ -4285,7 +4284,7 @@ function processSlotOutlet(node, context) {
|
|
|
4285
4284
|
}
|
|
4286
4285
|
}
|
|
4287
4286
|
if (nonNameProps.length > 0) {
|
|
4288
|
-
const { props, directives } = buildProps(node, context, nonNameProps);
|
|
4287
|
+
const { props, directives } = buildProps(node, context, nonNameProps, false, false);
|
|
4289
4288
|
slotProps = props;
|
|
4290
4289
|
if (directives.length) {
|
|
4291
4290
|
context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));
|
|
@@ -4456,11 +4455,7 @@ const transformText = (node, context) => {
|
|
|
4456
4455
|
const next = children[j];
|
|
4457
4456
|
if (isText(next)) {
|
|
4458
4457
|
if (!currentContainer) {
|
|
4459
|
-
currentContainer = children[i] =
|
|
4460
|
-
type: 8 /* COMPOUND_EXPRESSION */,
|
|
4461
|
-
loc: child.loc,
|
|
4462
|
-
children: [child]
|
|
4463
|
-
};
|
|
4458
|
+
currentContainer = children[i] = createCompoundExpression([child], child.loc);
|
|
4464
4459
|
}
|
|
4465
4460
|
// merge adjacent text node into current
|
|
4466
4461
|
currentContainer.children.push(` + `, next);
|
|
@@ -4855,4 +4850,4 @@ function baseCompile(template, options = {}) {
|
|
|
4855
4850
|
|
|
4856
4851
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
4857
4852
|
|
|
4858
|
-
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, 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, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, 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, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
|
4853
|
+
export { BASE_TRANSITION, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, 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, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, extractIdentifiers, findDir, findProp, generate, 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, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.34",
|
|
4
4
|
"description": "@vue/compiler-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/compiler-core.esm-bundler.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vue/shared": "3.2.
|
|
35
|
+
"@vue/shared": "3.2.34",
|
|
36
36
|
"@babel/parser": "^7.16.4",
|
|
37
37
|
"estree-walker": "^2.0.2",
|
|
38
38
|
"source-map": "^0.6.1"
|