@vue/compiler-core 3.5.12 → 3.5.14
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.14
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -339,12 +339,13 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
339
339
|
loc: locStub
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
|
-
function createCacheExpression(index, value, needPauseTracking = false) {
|
|
342
|
+
function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
|
|
343
343
|
return {
|
|
344
344
|
type: 20,
|
|
345
345
|
index,
|
|
346
346
|
value,
|
|
347
347
|
needPauseTracking,
|
|
348
|
+
inVOnce,
|
|
348
349
|
needArraySpread: false,
|
|
349
350
|
loc: locStub
|
|
350
351
|
};
|
|
@@ -1781,7 +1782,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1781
1782
|
if (parent.key === node) {
|
|
1782
1783
|
return !!parent.computed;
|
|
1783
1784
|
}
|
|
1784
|
-
return
|
|
1785
|
+
return true;
|
|
1785
1786
|
// no: class { NODE = value; }
|
|
1786
1787
|
// yes: class { [NODE] = value; }
|
|
1787
1788
|
// yes: class { key = NODE; }
|
|
@@ -2472,7 +2473,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2472
2473
|
"COMPILER_V_BIND_SYNC",
|
|
2473
2474
|
currentOptions,
|
|
2474
2475
|
currentProp.loc,
|
|
2475
|
-
currentProp.
|
|
2476
|
+
currentProp.arg.loc.source
|
|
2476
2477
|
)) {
|
|
2477
2478
|
currentProp.name = "model";
|
|
2478
2479
|
currentProp.modifiers.splice(syncIndex, 1);
|
|
@@ -3064,6 +3065,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3064
3065
|
}
|
|
3065
3066
|
}
|
|
3066
3067
|
let cachedAsArray = false;
|
|
3068
|
+
const slotCacheKeys = [];
|
|
3067
3069
|
if (toCache.length === children.length && node.type === 1) {
|
|
3068
3070
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
3069
3071
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -3073,6 +3075,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3073
3075
|
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3074
3076
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
3075
3077
|
if (slot) {
|
|
3078
|
+
slotCacheKeys.push(context.cached.length);
|
|
3076
3079
|
slot.returns = getCacheExpression(
|
|
3077
3080
|
createArrayExpression(slot.returns)
|
|
3078
3081
|
);
|
|
@@ -3082,6 +3085,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3082
3085
|
const slotName = findDir(node, "slot", true);
|
|
3083
3086
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
3084
3087
|
if (slot) {
|
|
3088
|
+
slotCacheKeys.push(context.cached.length);
|
|
3085
3089
|
slot.returns = getCacheExpression(
|
|
3086
3090
|
createArrayExpression(slot.returns)
|
|
3087
3091
|
);
|
|
@@ -3091,9 +3095,18 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3091
3095
|
}
|
|
3092
3096
|
if (!cachedAsArray) {
|
|
3093
3097
|
for (const child of toCache) {
|
|
3098
|
+
slotCacheKeys.push(context.cached.length);
|
|
3094
3099
|
child.codegenNode = context.cache(child.codegenNode);
|
|
3095
3100
|
}
|
|
3096
3101
|
}
|
|
3102
|
+
if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3103
|
+
node.codegenNode.children.properties.push(
|
|
3104
|
+
createObjectProperty(
|
|
3105
|
+
`__`,
|
|
3106
|
+
createSimpleExpression(JSON.stringify(slotCacheKeys), false)
|
|
3107
|
+
)
|
|
3108
|
+
);
|
|
3109
|
+
}
|
|
3097
3110
|
function getCacheExpression(value) {
|
|
3098
3111
|
const exp = context.cache(value);
|
|
3099
3112
|
if (inFor && context.hmr) {
|
|
@@ -3434,11 +3447,12 @@ function createTransformContext(root, {
|
|
|
3434
3447
|
identifier.hoisted = exp;
|
|
3435
3448
|
return identifier;
|
|
3436
3449
|
},
|
|
3437
|
-
cache(exp, isVNode = false) {
|
|
3450
|
+
cache(exp, isVNode = false, inVOnce = false) {
|
|
3438
3451
|
const cacheExp = createCacheExpression(
|
|
3439
3452
|
context.cached.length,
|
|
3440
3453
|
exp,
|
|
3441
|
-
isVNode
|
|
3454
|
+
isVNode,
|
|
3455
|
+
inVOnce
|
|
3442
3456
|
);
|
|
3443
3457
|
context.cached.push(cacheExp);
|
|
3444
3458
|
return cacheExp;
|
|
@@ -4294,7 +4308,9 @@ function genCacheExpression(node, context) {
|
|
|
4294
4308
|
push(`_cache[${node.index}] || (`);
|
|
4295
4309
|
if (needPauseTracking) {
|
|
4296
4310
|
indent();
|
|
4297
|
-
push(`${helper(SET_BLOCK_TRACKING)}(-1)
|
|
4311
|
+
push(`${helper(SET_BLOCK_TRACKING)}(-1`);
|
|
4312
|
+
if (node.inVOnce) push(`, true`);
|
|
4313
|
+
push(`),`);
|
|
4298
4314
|
newline();
|
|
4299
4315
|
push(`(`);
|
|
4300
4316
|
}
|
|
@@ -4382,12 +4398,14 @@ const transformExpression = (node, context) => {
|
|
|
4382
4398
|
context
|
|
4383
4399
|
);
|
|
4384
4400
|
} else if (node.type === 1) {
|
|
4401
|
+
const memo = findDir(node, "memo");
|
|
4385
4402
|
for (let i = 0; i < node.props.length; i++) {
|
|
4386
4403
|
const dir = node.props[i];
|
|
4387
4404
|
if (dir.type === 7 && dir.name !== "for") {
|
|
4388
4405
|
const exp = dir.exp;
|
|
4389
4406
|
const arg = dir.arg;
|
|
4390
|
-
if (exp && exp.type === 4 && !(dir.name === "on" && arg))
|
|
4407
|
+
if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
|
|
4408
|
+
!(memo && arg && arg.type === 4 && arg.content === "key")) {
|
|
4391
4409
|
dir.exp = processExpression(
|
|
4392
4410
|
exp,
|
|
4393
4411
|
context,
|
|
@@ -4915,10 +4933,19 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4915
4933
|
const isTemplate = isTemplateNode(node);
|
|
4916
4934
|
const memo = findDir(node, "memo");
|
|
4917
4935
|
const keyProp = findProp(node, `key`, false, true);
|
|
4918
|
-
|
|
4936
|
+
const isDirKey = keyProp && keyProp.type === 7;
|
|
4937
|
+
if (isDirKey && !keyProp.exp) {
|
|
4919
4938
|
transformBindShorthand(keyProp, context);
|
|
4920
4939
|
}
|
|
4921
|
-
|
|
4940
|
+
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4941
|
+
if (memo && keyExp && isDirKey) {
|
|
4942
|
+
{
|
|
4943
|
+
keyProp.exp = keyExp = processExpression(
|
|
4944
|
+
keyExp,
|
|
4945
|
+
context
|
|
4946
|
+
);
|
|
4947
|
+
}
|
|
4948
|
+
}
|
|
4922
4949
|
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4923
4950
|
if (isTemplate) {
|
|
4924
4951
|
if (memo) {
|
|
@@ -6310,8 +6337,8 @@ const transformOnce = (node, context) => {
|
|
|
6310
6337
|
if (cur.codegenNode) {
|
|
6311
6338
|
cur.codegenNode = context.cache(
|
|
6312
6339
|
cur.codegenNode,
|
|
6340
|
+
true,
|
|
6313
6341
|
true
|
|
6314
|
-
/* isVNode */
|
|
6315
6342
|
);
|
|
6316
6343
|
}
|
|
6317
6344
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.14
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -339,12 +339,13 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
339
339
|
loc: locStub
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
|
-
function createCacheExpression(index, value, needPauseTracking = false) {
|
|
342
|
+
function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
|
|
343
343
|
return {
|
|
344
344
|
type: 20,
|
|
345
345
|
index,
|
|
346
346
|
value,
|
|
347
347
|
needPauseTracking,
|
|
348
|
+
inVOnce,
|
|
348
349
|
needArraySpread: false,
|
|
349
350
|
loc: locStub
|
|
350
351
|
};
|
|
@@ -1777,7 +1778,7 @@ function isReferenced(node, parent, grandparent) {
|
|
|
1777
1778
|
if (parent.key === node) {
|
|
1778
1779
|
return !!parent.computed;
|
|
1779
1780
|
}
|
|
1780
|
-
return
|
|
1781
|
+
return true;
|
|
1781
1782
|
// no: class { NODE = value; }
|
|
1782
1783
|
// yes: class { [NODE] = value; }
|
|
1783
1784
|
// yes: class { key = NODE; }
|
|
@@ -2468,7 +2469,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2468
2469
|
"COMPILER_V_BIND_SYNC",
|
|
2469
2470
|
currentOptions,
|
|
2470
2471
|
currentProp.loc,
|
|
2471
|
-
currentProp.
|
|
2472
|
+
currentProp.arg.loc.source
|
|
2472
2473
|
)) {
|
|
2473
2474
|
currentProp.name = "model";
|
|
2474
2475
|
currentProp.modifiers.splice(syncIndex, 1);
|
|
@@ -3023,6 +3024,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3023
3024
|
}
|
|
3024
3025
|
}
|
|
3025
3026
|
let cachedAsArray = false;
|
|
3027
|
+
const slotCacheKeys = [];
|
|
3026
3028
|
if (toCache.length === children.length && node.type === 1) {
|
|
3027
3029
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
3028
3030
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -3032,6 +3034,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3032
3034
|
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3033
3035
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
3034
3036
|
if (slot) {
|
|
3037
|
+
slotCacheKeys.push(context.cached.length);
|
|
3035
3038
|
slot.returns = getCacheExpression(
|
|
3036
3039
|
createArrayExpression(slot.returns)
|
|
3037
3040
|
);
|
|
@@ -3041,6 +3044,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3041
3044
|
const slotName = findDir(node, "slot", true);
|
|
3042
3045
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
3043
3046
|
if (slot) {
|
|
3047
|
+
slotCacheKeys.push(context.cached.length);
|
|
3044
3048
|
slot.returns = getCacheExpression(
|
|
3045
3049
|
createArrayExpression(slot.returns)
|
|
3046
3050
|
);
|
|
@@ -3050,9 +3054,18 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
3050
3054
|
}
|
|
3051
3055
|
if (!cachedAsArray) {
|
|
3052
3056
|
for (const child of toCache) {
|
|
3057
|
+
slotCacheKeys.push(context.cached.length);
|
|
3053
3058
|
child.codegenNode = context.cache(child.codegenNode);
|
|
3054
3059
|
}
|
|
3055
3060
|
}
|
|
3061
|
+
if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !shared.isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
3062
|
+
node.codegenNode.children.properties.push(
|
|
3063
|
+
createObjectProperty(
|
|
3064
|
+
`__`,
|
|
3065
|
+
createSimpleExpression(JSON.stringify(slotCacheKeys), false)
|
|
3066
|
+
)
|
|
3067
|
+
);
|
|
3068
|
+
}
|
|
3056
3069
|
function getCacheExpression(value) {
|
|
3057
3070
|
const exp = context.cache(value);
|
|
3058
3071
|
if (inFor && context.hmr) {
|
|
@@ -3379,11 +3392,12 @@ function createTransformContext(root, {
|
|
|
3379
3392
|
identifier.hoisted = exp;
|
|
3380
3393
|
return identifier;
|
|
3381
3394
|
},
|
|
3382
|
-
cache(exp, isVNode = false) {
|
|
3395
|
+
cache(exp, isVNode = false, inVOnce = false) {
|
|
3383
3396
|
const cacheExp = createCacheExpression(
|
|
3384
3397
|
context.cached.length,
|
|
3385
3398
|
exp,
|
|
3386
|
-
isVNode
|
|
3399
|
+
isVNode,
|
|
3400
|
+
inVOnce
|
|
3387
3401
|
);
|
|
3388
3402
|
context.cached.push(cacheExp);
|
|
3389
3403
|
return cacheExp;
|
|
@@ -4218,7 +4232,9 @@ function genCacheExpression(node, context) {
|
|
|
4218
4232
|
push(`_cache[${node.index}] || (`);
|
|
4219
4233
|
if (needPauseTracking) {
|
|
4220
4234
|
indent();
|
|
4221
|
-
push(`${helper(SET_BLOCK_TRACKING)}(-1)
|
|
4235
|
+
push(`${helper(SET_BLOCK_TRACKING)}(-1`);
|
|
4236
|
+
if (node.inVOnce) push(`, true`);
|
|
4237
|
+
push(`),`);
|
|
4222
4238
|
newline();
|
|
4223
4239
|
push(`(`);
|
|
4224
4240
|
}
|
|
@@ -4306,12 +4322,14 @@ const transformExpression = (node, context) => {
|
|
|
4306
4322
|
context
|
|
4307
4323
|
);
|
|
4308
4324
|
} else if (node.type === 1) {
|
|
4325
|
+
const memo = findDir(node, "memo");
|
|
4309
4326
|
for (let i = 0; i < node.props.length; i++) {
|
|
4310
4327
|
const dir = node.props[i];
|
|
4311
4328
|
if (dir.type === 7 && dir.name !== "for") {
|
|
4312
4329
|
const exp = dir.exp;
|
|
4313
4330
|
const arg = dir.arg;
|
|
4314
|
-
if (exp && exp.type === 4 && !(dir.name === "on" && arg))
|
|
4331
|
+
if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
|
|
4332
|
+
!(memo && arg && arg.type === 4 && arg.content === "key")) {
|
|
4315
4333
|
dir.exp = processExpression(
|
|
4316
4334
|
exp,
|
|
4317
4335
|
context,
|
|
@@ -4830,10 +4848,19 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4830
4848
|
const isTemplate = isTemplateNode(node);
|
|
4831
4849
|
const memo = findDir(node, "memo");
|
|
4832
4850
|
const keyProp = findProp(node, `key`, false, true);
|
|
4833
|
-
|
|
4851
|
+
const isDirKey = keyProp && keyProp.type === 7;
|
|
4852
|
+
if (isDirKey && !keyProp.exp) {
|
|
4834
4853
|
transformBindShorthand(keyProp, context);
|
|
4835
4854
|
}
|
|
4836
|
-
|
|
4855
|
+
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4856
|
+
if (memo && keyExp && isDirKey) {
|
|
4857
|
+
{
|
|
4858
|
+
keyProp.exp = keyExp = processExpression(
|
|
4859
|
+
keyExp,
|
|
4860
|
+
context
|
|
4861
|
+
);
|
|
4862
|
+
}
|
|
4863
|
+
}
|
|
4837
4864
|
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4838
4865
|
if (isTemplate) {
|
|
4839
4866
|
if (memo) {
|
|
@@ -6192,8 +6219,8 @@ const transformOnce = (node, context) => {
|
|
|
6192
6219
|
if (cur.codegenNode) {
|
|
6193
6220
|
cur.codegenNode = context.cache(
|
|
6194
6221
|
cur.codegenNode,
|
|
6222
|
+
true,
|
|
6195
6223
|
true
|
|
6196
|
-
/* isVNode */
|
|
6197
6224
|
);
|
|
6198
6225
|
}
|
|
6199
6226
|
};
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
|
|
|
120
120
|
addIdentifiers(exp: ExpressionNode | string): void;
|
|
121
121
|
removeIdentifiers(exp: ExpressionNode | string): void;
|
|
122
122
|
hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
|
|
123
|
-
cache(exp: JSChildNode, isVNode?: boolean): CacheExpression;
|
|
123
|
+
cache(exp: JSChildNode, isVNode?: boolean, inVOnce?: boolean): CacheExpression;
|
|
124
124
|
constantCache: WeakMap<TemplateChildNode, ConstantTypes>;
|
|
125
125
|
filters?: Set<string>;
|
|
126
126
|
}
|
|
@@ -427,6 +427,7 @@ export interface CacheExpression extends Node {
|
|
|
427
427
|
index: number;
|
|
428
428
|
value: JSChildNode;
|
|
429
429
|
needPauseTracking: boolean;
|
|
430
|
+
inVOnce: boolean;
|
|
430
431
|
needArraySpread: boolean;
|
|
431
432
|
}
|
|
432
433
|
export interface MemoExpression extends CallExpression {
|
|
@@ -546,7 +547,7 @@ type InferCodegenNodeType<T> = T extends typeof RENDER_SLOT ? RenderSlotCall : C
|
|
|
546
547
|
export declare function createCallExpression<T extends CallExpression['callee']>(callee: T, args?: CallExpression['arguments'], loc?: SourceLocation): InferCodegenNodeType<T>;
|
|
547
548
|
export declare function createFunctionExpression(params: FunctionExpression['params'], returns?: FunctionExpression['returns'], newline?: boolean, isSlot?: boolean, loc?: SourceLocation): FunctionExpression;
|
|
548
549
|
export declare function createConditionalExpression(test: ConditionalExpression['test'], consequent: ConditionalExpression['consequent'], alternate: ConditionalExpression['alternate'], newline?: boolean): ConditionalExpression;
|
|
549
|
-
export declare function createCacheExpression(index: number, value: JSChildNode, needPauseTracking?: boolean): CacheExpression;
|
|
550
|
+
export declare function createCacheExpression(index: number, value: JSChildNode, needPauseTracking?: boolean, inVOnce?: boolean): CacheExpression;
|
|
550
551
|
export declare function createBlockStatement(body: BlockStatement['body']): BlockStatement;
|
|
551
552
|
export declare function createTemplateLiteral(elements: TemplateLiteral['elements']): TemplateLiteral;
|
|
552
553
|
export declare function createIfStatement(test: IfStatement['test'], consequent: IfStatement['consequent'], alternate?: IfStatement['alternate']): IfStatement;
|
|
@@ -1088,3 +1089,4 @@ export declare function processSlotOutlet(node: SlotOutletNode, context: Transfo
|
|
|
1088
1089
|
|
|
1089
1090
|
export declare function getConstantType(node: TemplateChildNode | SimpleExpressionNode | CacheExpression, context: TransformContext): ConstantTypes;
|
|
1090
1091
|
|
|
1092
|
+
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.5.
|
|
2
|
+
* @vue/compiler-core v3.5.14
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
import { isString, NOOP, isObject,
|
|
6
|
+
import { isString, NOOP, isObject, extend, NO, isSymbol, isArray, capitalize, camelize, EMPTY_OBJ, PatchFlagNames, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
|
|
7
7
|
export { generateCodeFrame } from '@vue/shared';
|
|
8
8
|
|
|
9
9
|
const FRAGMENT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Fragment` : ``);
|
|
@@ -332,12 +332,13 @@ function createConditionalExpression(test, consequent, alternate, newline = true
|
|
|
332
332
|
loc: locStub
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
|
-
function createCacheExpression(index, value, needPauseTracking = false) {
|
|
335
|
+
function createCacheExpression(index, value, needPauseTracking = false, inVOnce = false) {
|
|
336
336
|
return {
|
|
337
337
|
type: 20,
|
|
338
338
|
index,
|
|
339
339
|
value,
|
|
340
340
|
needPauseTracking,
|
|
341
|
+
inVOnce,
|
|
341
342
|
needArraySpread: false,
|
|
342
343
|
loc: locStub
|
|
343
344
|
};
|
|
@@ -1534,7 +1535,7 @@ function isForStatement(stmt) {
|
|
|
1534
1535
|
}
|
|
1535
1536
|
function walkForStatement(stmt, isVar, onIdent) {
|
|
1536
1537
|
const variable = stmt.type === "ForStatement" ? stmt.init : stmt.left;
|
|
1537
|
-
if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar :
|
|
1538
|
+
if (variable && variable.type === "VariableDeclaration" && (variable.kind === "var" ? isVar : false)) {
|
|
1538
1539
|
for (const decl of variable.declarations) {
|
|
1539
1540
|
for (const id of extractIdentifiers(decl.id)) {
|
|
1540
1541
|
onIdent(id);
|
|
@@ -2152,7 +2153,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
2152
2153
|
"COMPILER_V_BIND_SYNC",
|
|
2153
2154
|
currentOptions,
|
|
2154
2155
|
currentProp.loc,
|
|
2155
|
-
currentProp.
|
|
2156
|
+
currentProp.arg.loc.source
|
|
2156
2157
|
)) {
|
|
2157
2158
|
currentProp.name = "model";
|
|
2158
2159
|
currentProp.modifiers.splice(syncIndex, 1);
|
|
@@ -2728,6 +2729,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2728
2729
|
}
|
|
2729
2730
|
}
|
|
2730
2731
|
let cachedAsArray = false;
|
|
2732
|
+
const slotCacheKeys = [];
|
|
2731
2733
|
if (toCache.length === children.length && node.type === 1) {
|
|
2732
2734
|
if (node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
|
|
2733
2735
|
node.codegenNode.children = getCacheExpression(
|
|
@@ -2737,6 +2739,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2737
2739
|
} else if (node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2738
2740
|
const slot = getSlotNode(node.codegenNode, "default");
|
|
2739
2741
|
if (slot) {
|
|
2742
|
+
slotCacheKeys.push(context.cached.length);
|
|
2740
2743
|
slot.returns = getCacheExpression(
|
|
2741
2744
|
createArrayExpression(slot.returns)
|
|
2742
2745
|
);
|
|
@@ -2746,6 +2749,7 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2746
2749
|
const slotName = findDir(node, "slot", true);
|
|
2747
2750
|
const slot = slotName && slotName.arg && getSlotNode(parent.codegenNode, slotName.arg);
|
|
2748
2751
|
if (slot) {
|
|
2752
|
+
slotCacheKeys.push(context.cached.length);
|
|
2749
2753
|
slot.returns = getCacheExpression(
|
|
2750
2754
|
createArrayExpression(slot.returns)
|
|
2751
2755
|
);
|
|
@@ -2755,9 +2759,18 @@ function walk(node, parent, context, doNotHoistNode = false, inFor = false) {
|
|
|
2755
2759
|
}
|
|
2756
2760
|
if (!cachedAsArray) {
|
|
2757
2761
|
for (const child of toCache) {
|
|
2762
|
+
slotCacheKeys.push(context.cached.length);
|
|
2758
2763
|
child.codegenNode = context.cache(child.codegenNode);
|
|
2759
2764
|
}
|
|
2760
2765
|
}
|
|
2766
|
+
if (slotCacheKeys.length && node.type === 1 && node.tagType === 1 && node.codegenNode && node.codegenNode.type === 13 && node.codegenNode.children && !isArray(node.codegenNode.children) && node.codegenNode.children.type === 15) {
|
|
2767
|
+
node.codegenNode.children.properties.push(
|
|
2768
|
+
createObjectProperty(
|
|
2769
|
+
`__`,
|
|
2770
|
+
createSimpleExpression(JSON.stringify(slotCacheKeys), false)
|
|
2771
|
+
)
|
|
2772
|
+
);
|
|
2773
|
+
}
|
|
2761
2774
|
function getCacheExpression(value) {
|
|
2762
2775
|
const exp = context.cache(value);
|
|
2763
2776
|
if (inFor && context.hmr) {
|
|
@@ -3081,11 +3094,12 @@ function createTransformContext(root, {
|
|
|
3081
3094
|
identifier.hoisted = exp;
|
|
3082
3095
|
return identifier;
|
|
3083
3096
|
},
|
|
3084
|
-
cache(exp, isVNode = false) {
|
|
3097
|
+
cache(exp, isVNode = false, inVOnce = false) {
|
|
3085
3098
|
const cacheExp = createCacheExpression(
|
|
3086
3099
|
context.cached.length,
|
|
3087
3100
|
exp,
|
|
3088
|
-
isVNode
|
|
3101
|
+
isVNode,
|
|
3102
|
+
inVOnce
|
|
3089
3103
|
);
|
|
3090
3104
|
context.cached.push(cacheExp);
|
|
3091
3105
|
return cacheExp;
|
|
@@ -3800,7 +3814,9 @@ function genCacheExpression(node, context) {
|
|
|
3800
3814
|
push(`_cache[${node.index}] || (`);
|
|
3801
3815
|
if (needPauseTracking) {
|
|
3802
3816
|
indent();
|
|
3803
|
-
push(`${helper(SET_BLOCK_TRACKING)}(-1)
|
|
3817
|
+
push(`${helper(SET_BLOCK_TRACKING)}(-1`);
|
|
3818
|
+
if (node.inVOnce) push(`, true`);
|
|
3819
|
+
push(`),`);
|
|
3804
3820
|
newline();
|
|
3805
3821
|
push(`(`);
|
|
3806
3822
|
}
|
|
@@ -3857,12 +3873,14 @@ const transformExpression = (node, context) => {
|
|
|
3857
3873
|
context
|
|
3858
3874
|
);
|
|
3859
3875
|
} else if (node.type === 1) {
|
|
3876
|
+
const memo = findDir(node, "memo");
|
|
3860
3877
|
for (let i = 0; i < node.props.length; i++) {
|
|
3861
3878
|
const dir = node.props[i];
|
|
3862
3879
|
if (dir.type === 7 && dir.name !== "for") {
|
|
3863
3880
|
const exp = dir.exp;
|
|
3864
3881
|
const arg = dir.arg;
|
|
3865
|
-
if (exp && exp.type === 4 && !(dir.name === "on" && arg))
|
|
3882
|
+
if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
|
|
3883
|
+
!(memo && arg && arg.type === 4 && arg.content === "key")) {
|
|
3866
3884
|
dir.exp = processExpression(
|
|
3867
3885
|
exp,
|
|
3868
3886
|
context,
|
|
@@ -4199,10 +4217,11 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
4199
4217
|
const isTemplate = isTemplateNode(node);
|
|
4200
4218
|
const memo = findDir(node, "memo");
|
|
4201
4219
|
const keyProp = findProp(node, `key`, false, true);
|
|
4202
|
-
|
|
4220
|
+
const isDirKey = keyProp && keyProp.type === 7;
|
|
4221
|
+
if (isDirKey && !keyProp.exp) {
|
|
4203
4222
|
transformBindShorthand(keyProp);
|
|
4204
4223
|
}
|
|
4205
|
-
|
|
4224
|
+
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4206
4225
|
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4207
4226
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
4208
4227
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
@@ -5460,8 +5479,8 @@ const transformOnce = (node, context) => {
|
|
|
5460
5479
|
if (cur.codegenNode) {
|
|
5461
5480
|
cur.codegenNode = context.cache(
|
|
5462
5481
|
cur.codegenNode,
|
|
5482
|
+
true,
|
|
5463
5483
|
true
|
|
5464
|
-
/* isVNode */
|
|
5465
5484
|
);
|
|
5466
5485
|
}
|
|
5467
5486
|
};
|
|
@@ -5483,8 +5502,7 @@ const transformModel = (dir, node, context) => {
|
|
|
5483
5502
|
context.onError(createCompilerError(44, exp.loc));
|
|
5484
5503
|
return createTransformProps();
|
|
5485
5504
|
}
|
|
5486
|
-
|
|
5487
|
-
if (!expString.trim() || !isMemberExpression(exp) && !maybeRef) {
|
|
5505
|
+
if (!expString.trim() || !isMemberExpression(exp) && true) {
|
|
5488
5506
|
context.onError(
|
|
5489
5507
|
createCompilerError(42, exp.loc)
|
|
5490
5508
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.14",
|
|
4
4
|
"description": "@vue/compiler-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/compiler-core.esm-bundler.js",
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@babel/parser": "^7.
|
|
49
|
+
"@babel/parser": "^7.27.2",
|
|
50
50
|
"entities": "^4.5.0",
|
|
51
51
|
"estree-walker": "^2.0.2",
|
|
52
|
-
"source-map-js": "^1.2.
|
|
53
|
-
"@vue/shared": "3.5.
|
|
52
|
+
"source-map-js": "^1.2.1",
|
|
53
|
+
"@vue/shared": "3.5.14"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/types": "^7.
|
|
56
|
+
"@babel/types": "^7.27.1"
|
|
57
57
|
}
|
|
58
58
|
}
|