@vue/compiler-core 3.5.11 → 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.11
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
  };
@@ -2883,6 +2884,9 @@ function getLoc(start, end) {
2883
2884
  source: end == null ? end : getSlice(start, end)
2884
2885
  };
2885
2886
  }
2887
+ function cloneLoc(loc) {
2888
+ return getLoc(loc.start.offset, loc.end.offset);
2889
+ }
2886
2890
  function setLocEnd(loc, end) {
2887
2891
  loc.end = tokenizer.getPos(end);
2888
2892
  loc.source = getSlice(loc.start.offset, end);
@@ -3431,11 +3435,12 @@ function createTransformContext(root, {
3431
3435
  identifier.hoisted = exp;
3432
3436
  return identifier;
3433
3437
  },
3434
- cache(exp, isVNode = false) {
3438
+ cache(exp, isVNode = false, inVOnce = false) {
3435
3439
  const cacheExp = createCacheExpression(
3436
3440
  context.cached.length,
3437
3441
  exp,
3438
- isVNode
3442
+ isVNode,
3443
+ inVOnce
3439
3444
  );
3440
3445
  context.cached.push(cacheExp);
3441
3446
  return cacheExp;
@@ -4291,7 +4296,9 @@ function genCacheExpression(node, context) {
4291
4296
  push(`_cache[${node.index}] || (`);
4292
4297
  if (needPauseTracking) {
4293
4298
  indent();
4294
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4299
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
4300
+ if (node.inVOnce) push(`, true`);
4301
+ push(`),`);
4295
4302
  newline();
4296
4303
  push(`(`);
4297
4304
  }
@@ -4379,12 +4386,14 @@ const transformExpression = (node, context) => {
4379
4386
  context
4380
4387
  );
4381
4388
  } else if (node.type === 1) {
4389
+ const memo = findDir(node, "memo");
4382
4390
  for (let i = 0; i < node.props.length; i++) {
4383
4391
  const dir = node.props[i];
4384
4392
  if (dir.type === 7 && dir.name !== "for") {
4385
4393
  const exp = dir.exp;
4386
4394
  const arg = dir.arg;
4387
- 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")) {
4388
4397
  dir.exp = processExpression(
4389
4398
  exp,
4390
4399
  context,
@@ -4645,7 +4654,7 @@ function processIf(node, dir, context, processCodegen) {
4645
4654
  const branch = createIfBranch(node, dir);
4646
4655
  const ifNode = {
4647
4656
  type: 9,
4648
- loc: node.loc,
4657
+ loc: cloneLoc(node.loc),
4649
4658
  branches: [branch]
4650
4659
  };
4651
4660
  context.replaceNode(ifNode);
@@ -4912,10 +4921,19 @@ const transformFor = createStructuralDirectiveTransform(
4912
4921
  const isTemplate = isTemplateNode(node);
4913
4922
  const memo = findDir(node, "memo");
4914
4923
  const keyProp = findProp(node, `key`, false, true);
4915
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4924
+ const isDirKey = keyProp && keyProp.type === 7;
4925
+ if (isDirKey && !keyProp.exp) {
4916
4926
  transformBindShorthand(keyProp, context);
4917
4927
  }
4918
- 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
+ }
4919
4937
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4920
4938
  if (isTemplate) {
4921
4939
  if (memo) {
@@ -6307,8 +6325,8 @@ const transformOnce = (node, context) => {
6307
6325
  if (cur.codegenNode) {
6308
6326
  cur.codegenNode = context.cache(
6309
6327
  cur.codegenNode,
6328
+ true,
6310
6329
  true
6311
- /* isVNode */
6312
6330
  );
6313
6331
  }
6314
6332
  };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.11
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
  };
@@ -2849,6 +2850,9 @@ function getLoc(start, end) {
2849
2850
  source: end == null ? end : getSlice(start, end)
2850
2851
  };
2851
2852
  }
2853
+ function cloneLoc(loc) {
2854
+ return getLoc(loc.start.offset, loc.end.offset);
2855
+ }
2852
2856
  function setLocEnd(loc, end) {
2853
2857
  loc.end = tokenizer.getPos(end);
2854
2858
  loc.source = getSlice(loc.start.offset, end);
@@ -3376,11 +3380,12 @@ function createTransformContext(root, {
3376
3380
  identifier.hoisted = exp;
3377
3381
  return identifier;
3378
3382
  },
3379
- cache(exp, isVNode = false) {
3383
+ cache(exp, isVNode = false, inVOnce = false) {
3380
3384
  const cacheExp = createCacheExpression(
3381
3385
  context.cached.length,
3382
3386
  exp,
3383
- isVNode
3387
+ isVNode,
3388
+ inVOnce
3384
3389
  );
3385
3390
  context.cached.push(cacheExp);
3386
3391
  return cacheExp;
@@ -4215,7 +4220,9 @@ function genCacheExpression(node, context) {
4215
4220
  push(`_cache[${node.index}] || (`);
4216
4221
  if (needPauseTracking) {
4217
4222
  indent();
4218
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
4223
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
4224
+ if (node.inVOnce) push(`, true`);
4225
+ push(`),`);
4219
4226
  newline();
4220
4227
  push(`(`);
4221
4228
  }
@@ -4303,12 +4310,14 @@ const transformExpression = (node, context) => {
4303
4310
  context
4304
4311
  );
4305
4312
  } else if (node.type === 1) {
4313
+ const memo = findDir(node, "memo");
4306
4314
  for (let i = 0; i < node.props.length; i++) {
4307
4315
  const dir = node.props[i];
4308
4316
  if (dir.type === 7 && dir.name !== "for") {
4309
4317
  const exp = dir.exp;
4310
4318
  const arg = dir.arg;
4311
- 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")) {
4312
4321
  dir.exp = processExpression(
4313
4322
  exp,
4314
4323
  context,
@@ -4569,7 +4578,7 @@ function processIf(node, dir, context, processCodegen) {
4569
4578
  const branch = createIfBranch(node, dir);
4570
4579
  const ifNode = {
4571
4580
  type: 9,
4572
- loc: node.loc,
4581
+ loc: cloneLoc(node.loc),
4573
4582
  branches: [branch]
4574
4583
  };
4575
4584
  context.replaceNode(ifNode);
@@ -4827,10 +4836,19 @@ const transformFor = createStructuralDirectiveTransform(
4827
4836
  const isTemplate = isTemplateNode(node);
4828
4837
  const memo = findDir(node, "memo");
4829
4838
  const keyProp = findProp(node, `key`, false, true);
4830
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4839
+ const isDirKey = keyProp && keyProp.type === 7;
4840
+ if (isDirKey && !keyProp.exp) {
4831
4841
  transformBindShorthand(keyProp, context);
4832
4842
  }
4833
- 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
+ }
4834
4852
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4835
4853
  if (isTemplate) {
4836
4854
  if (memo) {
@@ -6189,8 +6207,8 @@ const transformOnce = (node, context) => {
6189
6207
  if (cur.codegenNode) {
6190
6208
  cur.codegenNode = context.cache(
6191
6209
  cur.codegenNode,
6210
+ true,
6192
6211
  true
6193
- /* isVNode */
6194
6212
  );
6195
6213
  }
6196
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.11
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
  };
@@ -2569,6 +2570,9 @@ function getLoc(start, end) {
2569
2570
  source: end == null ? end : getSlice(start, end)
2570
2571
  };
2571
2572
  }
2573
+ function cloneLoc(loc) {
2574
+ return getLoc(loc.start.offset, loc.end.offset);
2575
+ }
2572
2576
  function setLocEnd(loc, end) {
2573
2577
  loc.end = tokenizer.getPos(end);
2574
2578
  loc.source = getSlice(loc.start.offset, end);
@@ -3078,11 +3082,12 @@ function createTransformContext(root, {
3078
3082
  identifier.hoisted = exp;
3079
3083
  return identifier;
3080
3084
  },
3081
- cache(exp, isVNode = false) {
3085
+ cache(exp, isVNode = false, inVOnce = false) {
3082
3086
  const cacheExp = createCacheExpression(
3083
3087
  context.cached.length,
3084
3088
  exp,
3085
- isVNode
3089
+ isVNode,
3090
+ inVOnce
3086
3091
  );
3087
3092
  context.cached.push(cacheExp);
3088
3093
  return cacheExp;
@@ -3797,7 +3802,9 @@ function genCacheExpression(node, context) {
3797
3802
  push(`_cache[${node.index}] || (`);
3798
3803
  if (needPauseTracking) {
3799
3804
  indent();
3800
- push(`${helper(SET_BLOCK_TRACKING)}(-1),`);
3805
+ push(`${helper(SET_BLOCK_TRACKING)}(-1`);
3806
+ if (node.inVOnce) push(`, true`);
3807
+ push(`),`);
3801
3808
  newline();
3802
3809
  push(`(`);
3803
3810
  }
@@ -3854,12 +3861,14 @@ const transformExpression = (node, context) => {
3854
3861
  context
3855
3862
  );
3856
3863
  } else if (node.type === 1) {
3864
+ const memo = findDir(node, "memo");
3857
3865
  for (let i = 0; i < node.props.length; i++) {
3858
3866
  const dir = node.props[i];
3859
3867
  if (dir.type === 7 && dir.name !== "for") {
3860
3868
  const exp = dir.exp;
3861
3869
  const arg = dir.arg;
3862
- 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")) {
3863
3872
  dir.exp = processExpression(
3864
3873
  exp,
3865
3874
  context,
@@ -3939,7 +3948,7 @@ function processIf(node, dir, context, processCodegen) {
3939
3948
  const branch = createIfBranch(node, dir);
3940
3949
  const ifNode = {
3941
3950
  type: 9,
3942
- loc: node.loc,
3951
+ loc: cloneLoc(node.loc),
3943
3952
  branches: [branch]
3944
3953
  };
3945
3954
  context.replaceNode(ifNode);
@@ -4196,10 +4205,11 @@ const transformFor = createStructuralDirectiveTransform(
4196
4205
  const isTemplate = isTemplateNode(node);
4197
4206
  const memo = findDir(node, "memo");
4198
4207
  const keyProp = findProp(node, `key`, false, true);
4199
- if (keyProp && keyProp.type === 7 && !keyProp.exp) {
4208
+ const isDirKey = keyProp && keyProp.type === 7;
4209
+ if (isDirKey && !keyProp.exp) {
4200
4210
  transformBindShorthand(keyProp);
4201
4211
  }
4202
- 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);
4203
4213
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4204
4214
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
4205
4215
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
@@ -5457,8 +5467,8 @@ const transformOnce = (node, context) => {
5457
5467
  if (cur.codegenNode) {
5458
5468
  cur.codegenNode = context.cache(
5459
5469
  cur.codegenNode,
5470
+ true,
5460
5471
  true
5461
- /* isVNode */
5462
5472
  );
5463
5473
  }
5464
5474
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.5.11",
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.11"
53
+ "@vue/shared": "3.5.13"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.25.2"