@vue/compiler-core 3.5.12 → 3.5.13

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.12
2
+ * @vue/compiler-core v3.5.13
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
  };
@@ -3434,11 +3435,12 @@ function createTransformContext(root, {
3434
3435
  identifier.hoisted = exp;
3435
3436
  return identifier;
3436
3437
  },
3437
- cache(exp, isVNode = false) {
3438
+ cache(exp, isVNode = false, inVOnce = false) {
3438
3439
  const cacheExp = createCacheExpression(
3439
3440
  context.cached.length,
3440
3441
  exp,
3441
- isVNode
3442
+ isVNode,
3443
+ inVOnce
3442
3444
  );
3443
3445
  context.cached.push(cacheExp);
3444
3446
  return cacheExp;
@@ -4294,7 +4296,9 @@ function genCacheExpression(node, context) {
4294
4296
  push(`_cache[${node.index}] || (`);
4295
4297
  if (needPauseTracking) {
4296
4298
  indent();
4297
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4299
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
4300
+ if (node.inVOnce) push(`, true`);
4301
+ push(`),`);
4298
4302
  newline();
4299
4303
  push(`(`);
4300
4304
  }
@@ -4382,12 +4386,14 @@ const transformExpression = (node, context) => {
4382
4386
  context
4383
4387
  );
4384
4388
  } else if (node.type === 1) {
4389
+ const memo = findDir(node, "memo");
4385
4390
  for (let i = 0; i < node.props.length; i++) {
4386
4391
  const dir = node.props[i];
4387
4392
  if (dir.type === 7 && dir.name !== "for") {
4388
4393
  const exp = dir.exp;
4389
4394
  const arg = dir.arg;
4390
- if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
4395
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
4396
+ !(memo && arg && arg.type === 4 && arg.content === "key")) {
4391
4397
  dir.exp = processExpression(
4392
4398
  exp,
4393
4399
  context,
@@ -4915,10 +4921,19 @@ const transformFor = createStructuralDirectiveTransform(
4915
4921
  const isTemplate = isTemplateNode(node);
4916
4922
  const memo = findDir(node, "memo");
4917
4923
  const keyProp = findProp(node, `key`, false, true);
4918
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4924
+ const isDirKey = keyProp && keyProp.type === 7;
4925
+ if (isDirKey && !keyProp.exp) {
4919
4926
  transformBindShorthand(keyProp, context);
4920
4927
  }
4921
- const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4928
+ let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4929
+ if (memo && keyExp && isDirKey) {
4930
+ {
4931
+ keyProp.exp = keyExp = processExpression(
4932
+ keyExp,
4933
+ context
4934
+ );
4935
+ }
4936
+ }
4922
4937
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4923
4938
  if (isTemplate) {
4924
4939
  if (memo) {
@@ -6310,8 +6325,8 @@ const transformOnce = (node, context) => {
6310
6325
  if (cur.codegenNode) {
6311
6326
  cur.codegenNode = context.cache(
6312
6327
  cur.codegenNode,
6328
+ true,
6313
6329
  true
6314
- /* isVNode */
6315
6330
  );
6316
6331
  }
6317
6332
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.12
2
+ * @vue/compiler-core v3.5.13
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
  };
@@ -3379,11 +3380,12 @@ function createTransformContext(root, {
3379
3380
  identifier.hoisted = exp;
3380
3381
  return identifier;
3381
3382
  },
3382
- cache(exp, isVNode = false) {
3383
+ cache(exp, isVNode = false, inVOnce = false) {
3383
3384
  const cacheExp = createCacheExpression(
3384
3385
  context.cached.length,
3385
3386
  exp,
3386
- isVNode
3387
+ isVNode,
3388
+ inVOnce
3387
3389
  );
3388
3390
  context.cached.push(cacheExp);
3389
3391
  return cacheExp;
@@ -4218,7 +4220,9 @@ function genCacheExpression(node, context) {
4218
4220
  push(`_cache[${node.index}] || (`);
4219
4221
  if (needPauseTracking) {
4220
4222
  indent();
4221
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4223
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
4224
+ if (node.inVOnce) push(`, true`);
4225
+ push(`),`);
4222
4226
  newline();
4223
4227
  push(`(`);
4224
4228
  }
@@ -4306,12 +4310,14 @@ const transformExpression = (node, context) => {
4306
4310
  context
4307
4311
  );
4308
4312
  } else if (node.type === 1) {
4313
+ const memo = findDir(node, "memo");
4309
4314
  for (let i = 0; i < node.props.length; i++) {
4310
4315
  const dir = node.props[i];
4311
4316
  if (dir.type === 7 && dir.name !== "for") {
4312
4317
  const exp = dir.exp;
4313
4318
  const arg = dir.arg;
4314
- if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
4319
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
4320
+ !(memo && arg && arg.type === 4 && arg.content === "key")) {
4315
4321
  dir.exp = processExpression(
4316
4322
  exp,
4317
4323
  context,
@@ -4830,10 +4836,19 @@ const transformFor = createStructuralDirectiveTransform(
4830
4836
  const isTemplate = isTemplateNode(node);
4831
4837
  const memo = findDir(node, "memo");
4832
4838
  const keyProp = findProp(node, `key`, false, true);
4833
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4839
+ const isDirKey = keyProp && keyProp.type === 7;
4840
+ if (isDirKey && !keyProp.exp) {
4834
4841
  transformBindShorthand(keyProp, context);
4835
4842
  }
4836
- const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4843
+ let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4844
+ if (memo && keyExp && isDirKey) {
4845
+ {
4846
+ keyProp.exp = keyExp = processExpression(
4847
+ keyExp,
4848
+ context
4849
+ );
4850
+ }
4851
+ }
4837
4852
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4838
4853
  if (isTemplate) {
4839
4854
  if (memo) {
@@ -6192,8 +6207,8 @@ const transformOnce = (node, context) => {
6192
6207
  if (cur.codegenNode) {
6193
6208
  cur.codegenNode = context.cache(
6194
6209
  cur.codegenNode,
6210
+ true,
6195
6211
  true
6196
- /* isVNode */
6197
6212
  );
6198
6213
  }
6199
6214
  };
@@ -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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.12
2
+ * @vue/compiler-core v3.5.13
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -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
  };
@@ -3081,11 +3082,12 @@ function createTransformContext(root, {
3081
3082
  identifier.hoisted = exp;
3082
3083
  return identifier;
3083
3084
  },
3084
- cache(exp, isVNode = false) {
3085
+ cache(exp, isVNode = false, inVOnce = false) {
3085
3086
  const cacheExp = createCacheExpression(
3086
3087
  context.cached.length,
3087
3088
  exp,
3088
- isVNode
3089
+ isVNode,
3090
+ inVOnce
3089
3091
  );
3090
3092
  context.cached.push(cacheExp);
3091
3093
  return cacheExp;
@@ -3800,7 +3802,9 @@ function genCacheExpression(node, context) {
3800
3802
  push(`_cache[${node.index}] || (`);
3801
3803
  if (needPauseTracking) {
3802
3804
  indent();
3803
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
3805
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
3806
+ if (node.inVOnce) push(`, true`);
3807
+ push(`),`);
3804
3808
  newline();
3805
3809
  push(`(`);
3806
3810
  }
@@ -3857,12 +3861,14 @@ const transformExpression = (node, context) => {
3857
3861
  context
3858
3862
  );
3859
3863
  } else if (node.type === 1) {
3864
+ const memo = findDir(node, "memo");
3860
3865
  for (let i = 0; i < node.props.length; i++) {
3861
3866
  const dir = node.props[i];
3862
3867
  if (dir.type === 7 && dir.name !== "for") {
3863
3868
  const exp = dir.exp;
3864
3869
  const arg = dir.arg;
3865
- if (exp && exp.type === 4 && !(dir.name === "on" && arg)) {
3870
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && // key has been processed in transformFor(vMemo + vFor)
3871
+ !(memo && arg && arg.type === 4 && arg.content === "key")) {
3866
3872
  dir.exp = processExpression(
3867
3873
  exp,
3868
3874
  context,
@@ -4199,10 +4205,11 @@ const transformFor = createStructuralDirectiveTransform(
4199
4205
  const isTemplate = isTemplateNode(node);
4200
4206
  const memo = findDir(node, "memo");
4201
4207
  const keyProp = findProp(node, `key`, false, true);
4202
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4208
+ const isDirKey = keyProp && keyProp.type === 7;
4209
+ if (isDirKey && !keyProp.exp) {
4203
4210
  transformBindShorthand(keyProp);
4204
4211
  }
4205
- const keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4212
+ let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4206
4213
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4207
4214
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
4208
4215
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
@@ -5460,8 +5467,8 @@ const transformOnce = (node, context) => {
5460
5467
  if (cur.codegenNode) {
5461
5468
  cur.codegenNode = context.cache(
5462
5469
  cur.codegenNode,
5470
+ true,
5463
5471
  true
5464
- /* isVNode */
5465
5472
  );
5466
5473
  }
5467
5474
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.5.12",
3
+ "version": "3.5.13",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -50,7 +50,7 @@
50
50
  "entities": "^4.5.0",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.0",
53
- "@vue/shared": "3.5.12"
53
+ "@vue/shared": "3.5.13"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.25.2"