@vue/compiler-core 3.5.39 → 3.5.41

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.39
2
+ * @vue/compiler-core v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2159,6 +2159,9 @@ function getUnnormalizedProps(props, callPath = []) {
2159
2159
  return [props, callPath];
2160
2160
  }
2161
2161
  function injectProp(node, prop, context) {
2162
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
2163
+ return;
2164
+ }
2162
2165
  let propsWithInjection;
2163
2166
  let props = node.type === 13 ? node.props : node.arguments[2];
2164
2167
  let callPath = [];
@@ -2216,6 +2219,24 @@ function injectProp(node, prop, context) {
2216
2219
  }
2217
2220
  }
2218
2221
  }
2222
+ function injectSlotKey(node, prop) {
2223
+ var _a, _b, _c;
2224
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
2225
+ return false;
2226
+ }
2227
+ const props = node.arguments[2];
2228
+ if (props && !shared.isString(props)) {
2229
+ const [unnormalizedProps] = getUnnormalizedProps(props);
2230
+ if (unnormalizedProps && !shared.isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
2231
+ return true;
2232
+ }
2233
+ }
2234
+ (_a = node.arguments)[2] || (_a[2] = "{}");
2235
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
2236
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
2237
+ node.arguments[5] = prop.value;
2238
+ return true;
2239
+ }
2219
2240
  function hasProp(prop, props) {
2220
2241
  let result = false;
2221
2242
  if (prop.key.type === 4) {
@@ -4942,6 +4963,7 @@ const transformFor = createStructuralDirectiveTransform(
4942
4963
  node.loc
4943
4964
  );
4944
4965
  return () => {
4966
+ var _a;
4945
4967
  let childBlock;
4946
4968
  const { children } = forNode;
4947
4969
  if (isTemplate) {
@@ -4985,7 +5007,8 @@ const transformFor = createStructuralDirectiveTransform(
4985
5007
  if (isTemplate && keyProperty) {
4986
5008
  injectProp(childBlock, keyProperty, context);
4987
5009
  }
4988
- if (childBlock.isBlock !== !isStableFragment) {
5010
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
5011
+ if (childBlock.isBlock !== shouldUseBlock) {
4989
5012
  if (childBlock.isBlock) {
4990
5013
  removeHelper(OPEN_BLOCK);
4991
5014
  removeHelper(
@@ -4997,12 +5020,15 @@ const transformFor = createStructuralDirectiveTransform(
4997
5020
  );
4998
5021
  }
4999
5022
  }
5000
- childBlock.isBlock = !isStableFragment;
5023
+ childBlock.isBlock = shouldUseBlock;
5001
5024
  if (childBlock.isBlock) {
5002
5025
  helper(OPEN_BLOCK);
5003
5026
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
5004
5027
  } else {
5005
5028
  helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
5029
+ if (childBlock.needsPatch) {
5030
+ childBlock.patchFlag = ((_a = childBlock.patchFlag) != null ? _a : 0) | 512;
5031
+ }
5006
5032
  }
5007
5033
  }
5008
5034
  if (memo) {
@@ -5424,6 +5450,8 @@ const transformElement = (node, context) => {
5424
5450
  let vnodeDynamicProps;
5425
5451
  let dynamicPropNames;
5426
5452
  let vnodeDirectives;
5453
+ let needsPatch = false;
5454
+ let isBlockRequired = false;
5427
5455
  let shouldUseBlock = (
5428
5456
  // dynamic component may resolve to plain elements
5429
5457
  isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
@@ -5443,6 +5471,8 @@ const transformElement = (node, context) => {
5443
5471
  vnodeProps = propsBuildResult.props;
5444
5472
  patchFlag = propsBuildResult.patchFlag;
5445
5473
  dynamicPropNames = propsBuildResult.dynamicPropNames;
5474
+ needsPatch = propsBuildResult.needsPatch;
5475
+ isBlockRequired = propsBuildResult.isBlockRequired;
5446
5476
  const directives = propsBuildResult.directives;
5447
5477
  vnodeDirectives = directives && directives.length ? createArrayExpression(
5448
5478
  directives.map((dir) => buildDirectiveArgs(dir, context))
@@ -5493,7 +5523,7 @@ const transformElement = (node, context) => {
5493
5523
  if (dynamicPropNames && dynamicPropNames.length) {
5494
5524
  vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5495
5525
  }
5496
- node.codegenNode = createVNodeCall(
5526
+ const vnodeCall = node.codegenNode = createVNodeCall(
5497
5527
  context,
5498
5528
  vnodeTag,
5499
5529
  vnodeProps,
@@ -5506,6 +5536,13 @@ const transformElement = (node, context) => {
5506
5536
  isComponent,
5507
5537
  node.loc
5508
5538
  );
5539
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
5540
+ if (needsPatch) {
5541
+ vnodeCall.needsPatch = true;
5542
+ }
5543
+ if (isBlockRequired) {
5544
+ vnodeCall.isBlockRequired = true;
5545
+ }
5509
5546
  };
5510
5547
  };
5511
5548
  function resolveComponentType(node, context, ssr = false) {
@@ -5615,6 +5652,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5615
5652
  const runtimeDirectives = [];
5616
5653
  const hasChildren = children.length > 0;
5617
5654
  let shouldUseBlock = false;
5655
+ let isBlockRequired = false;
5618
5656
  let patchFlag = 0;
5619
5657
  let hasRef = false;
5620
5658
  let hasClassBinding = false;
@@ -5656,19 +5694,20 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5656
5694
  if (isEventHandler && shared.isReservedProp(name)) {
5657
5695
  hasVnodeHook = true;
5658
5696
  }
5697
+ if (name === "ref") {
5698
+ hasRef = true;
5699
+ }
5659
5700
  if (isEventHandler && value.type === 14) {
5660
5701
  value = value.arguments[0];
5661
5702
  }
5662
5703
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
5663
5704
  return;
5664
5705
  }
5665
- if (name === "ref") {
5666
- hasRef = true;
5667
- } else if (name === "class") {
5706
+ if (name === "class") {
5668
5707
  hasClassBinding = true;
5669
5708
  } else if (name === "style") {
5670
5709
  hasStyleBinding = true;
5671
- } else if (name !== "key" && !dynamicPropNames.includes(name)) {
5710
+ } else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) {
5672
5711
  dynamicPropNames.push(name);
5673
5712
  }
5674
5713
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
@@ -5739,13 +5778,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5739
5778
  if (isVOn && ssr) {
5740
5779
  continue;
5741
5780
  }
5742
- if (
5743
- // #938: elements with dynamic keys should be forced into blocks
5744
- isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
5745
- // before children
5746
- isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
5747
- ) {
5781
+ if (isVBind && isStaticArgOf(arg, "key")) {
5782
+ shouldUseBlock = true;
5783
+ }
5784
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && shared.camelize(arg.content) === "vue:beforeUpdate") {
5748
5785
  shouldUseBlock = true;
5786
+ isBlockRequired = true;
5749
5787
  }
5750
5788
  if (isVBind && isStaticArgOf(arg, "ref")) {
5751
5789
  pushRefVForMarker();
@@ -5828,6 +5866,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5828
5866
  runtimeDirectives.push(prop);
5829
5867
  if (hasChildren) {
5830
5868
  shouldUseBlock = true;
5869
+ isBlockRequired = true;
5831
5870
  }
5832
5871
  }
5833
5872
  }
@@ -5866,7 +5905,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5866
5905
  patchFlag |= 32;
5867
5906
  }
5868
5907
  }
5869
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
5908
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
5909
+ if (!shouldUseBlock && needsPatch) {
5870
5910
  patchFlag |= 512;
5871
5911
  }
5872
5912
  if (!context.inSSR && propsExpression) {
@@ -5932,7 +5972,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5932
5972
  directives: runtimeDirectives,
5933
5973
  patchFlag,
5934
5974
  dynamicPropNames,
5935
- shouldUseBlock
5975
+ shouldUseBlock,
5976
+ needsPatch,
5977
+ isBlockRequired
5936
5978
  };
5937
5979
  }
5938
5980
  function dedupeProperties(properties) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.39
2
+ * @vue/compiler-core v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2155,6 +2155,9 @@ function getUnnormalizedProps(props, callPath = []) {
2155
2155
  return [props, callPath];
2156
2156
  }
2157
2157
  function injectProp(node, prop, context) {
2158
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
2159
+ return;
2160
+ }
2158
2161
  let propsWithInjection;
2159
2162
  let props = node.type === 13 ? node.props : node.arguments[2];
2160
2163
  let callPath = [];
@@ -2212,6 +2215,24 @@ function injectProp(node, prop, context) {
2212
2215
  }
2213
2216
  }
2214
2217
  }
2218
+ function injectSlotKey(node, prop) {
2219
+ var _a, _b, _c;
2220
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
2221
+ return false;
2222
+ }
2223
+ const props = node.arguments[2];
2224
+ if (props && !shared.isString(props)) {
2225
+ const [unnormalizedProps] = getUnnormalizedProps(props);
2226
+ if (unnormalizedProps && !shared.isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
2227
+ return true;
2228
+ }
2229
+ }
2230
+ (_a = node.arguments)[2] || (_a[2] = "{}");
2231
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
2232
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
2233
+ node.arguments[5] = prop.value;
2234
+ return true;
2235
+ }
2215
2236
  function hasProp(prop, props) {
2216
2237
  let result = false;
2217
2238
  if (prop.key.type === 4) {
@@ -4855,6 +4876,7 @@ const transformFor = createStructuralDirectiveTransform(
4855
4876
  node.loc
4856
4877
  );
4857
4878
  return () => {
4879
+ var _a;
4858
4880
  let childBlock;
4859
4881
  const { children } = forNode;
4860
4882
  if (isTemplate) {
@@ -4898,7 +4920,8 @@ const transformFor = createStructuralDirectiveTransform(
4898
4920
  if (isTemplate && keyProperty) {
4899
4921
  injectProp(childBlock, keyProperty, context);
4900
4922
  }
4901
- if (childBlock.isBlock !== !isStableFragment) {
4923
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
4924
+ if (childBlock.isBlock !== shouldUseBlock) {
4902
4925
  if (childBlock.isBlock) {
4903
4926
  removeHelper(OPEN_BLOCK);
4904
4927
  removeHelper(
@@ -4910,12 +4933,15 @@ const transformFor = createStructuralDirectiveTransform(
4910
4933
  );
4911
4934
  }
4912
4935
  }
4913
- childBlock.isBlock = !isStableFragment;
4936
+ childBlock.isBlock = shouldUseBlock;
4914
4937
  if (childBlock.isBlock) {
4915
4938
  helper(OPEN_BLOCK);
4916
4939
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
4917
4940
  } else {
4918
4941
  helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
4942
+ if (childBlock.needsPatch) {
4943
+ childBlock.patchFlag = ((_a = childBlock.patchFlag) != null ? _a : 0) | 512;
4944
+ }
4919
4945
  }
4920
4946
  }
4921
4947
  if (memo) {
@@ -5337,6 +5363,8 @@ const transformElement = (node, context) => {
5337
5363
  let vnodeDynamicProps;
5338
5364
  let dynamicPropNames;
5339
5365
  let vnodeDirectives;
5366
+ let needsPatch = false;
5367
+ let isBlockRequired = false;
5340
5368
  let shouldUseBlock = (
5341
5369
  // dynamic component may resolve to plain elements
5342
5370
  isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
@@ -5356,6 +5384,8 @@ const transformElement = (node, context) => {
5356
5384
  vnodeProps = propsBuildResult.props;
5357
5385
  patchFlag = propsBuildResult.patchFlag;
5358
5386
  dynamicPropNames = propsBuildResult.dynamicPropNames;
5387
+ needsPatch = propsBuildResult.needsPatch;
5388
+ isBlockRequired = propsBuildResult.isBlockRequired;
5359
5389
  const directives = propsBuildResult.directives;
5360
5390
  vnodeDirectives = directives && directives.length ? createArrayExpression(
5361
5391
  directives.map((dir) => buildDirectiveArgs(dir, context))
@@ -5397,7 +5427,7 @@ const transformElement = (node, context) => {
5397
5427
  if (dynamicPropNames && dynamicPropNames.length) {
5398
5428
  vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
5399
5429
  }
5400
- node.codegenNode = createVNodeCall(
5430
+ const vnodeCall = node.codegenNode = createVNodeCall(
5401
5431
  context,
5402
5432
  vnodeTag,
5403
5433
  vnodeProps,
@@ -5410,6 +5440,13 @@ const transformElement = (node, context) => {
5410
5440
  isComponent,
5411
5441
  node.loc
5412
5442
  );
5443
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
5444
+ if (needsPatch) {
5445
+ vnodeCall.needsPatch = true;
5446
+ }
5447
+ if (isBlockRequired) {
5448
+ vnodeCall.isBlockRequired = true;
5449
+ }
5413
5450
  };
5414
5451
  };
5415
5452
  function resolveComponentType(node, context, ssr = false) {
@@ -5519,6 +5556,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5519
5556
  const runtimeDirectives = [];
5520
5557
  const hasChildren = children.length > 0;
5521
5558
  let shouldUseBlock = false;
5559
+ let isBlockRequired = false;
5522
5560
  let patchFlag = 0;
5523
5561
  let hasRef = false;
5524
5562
  let hasClassBinding = false;
@@ -5560,19 +5598,20 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5560
5598
  if (isEventHandler && shared.isReservedProp(name)) {
5561
5599
  hasVnodeHook = true;
5562
5600
  }
5601
+ if (name === "ref") {
5602
+ hasRef = true;
5603
+ }
5563
5604
  if (isEventHandler && value.type === 14) {
5564
5605
  value = value.arguments[0];
5565
5606
  }
5566
5607
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
5567
5608
  return;
5568
5609
  }
5569
- if (name === "ref") {
5570
- hasRef = true;
5571
- } else if (name === "class") {
5610
+ if (name === "class") {
5572
5611
  hasClassBinding = true;
5573
5612
  } else if (name === "style") {
5574
5613
  hasStyleBinding = true;
5575
- } else if (name !== "key" && !dynamicPropNames.includes(name)) {
5614
+ } else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) {
5576
5615
  dynamicPropNames.push(name);
5577
5616
  }
5578
5617
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
@@ -5643,13 +5682,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5643
5682
  if (isVOn && ssr) {
5644
5683
  continue;
5645
5684
  }
5646
- if (
5647
- // #938: elements with dynamic keys should be forced into blocks
5648
- isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
5649
- // before children
5650
- isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
5651
- ) {
5685
+ if (isVBind && isStaticArgOf(arg, "key")) {
5686
+ shouldUseBlock = true;
5687
+ }
5688
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && shared.camelize(arg.content) === "vue:beforeUpdate") {
5652
5689
  shouldUseBlock = true;
5690
+ isBlockRequired = true;
5653
5691
  }
5654
5692
  if (isVBind && isStaticArgOf(arg, "ref")) {
5655
5693
  pushRefVForMarker();
@@ -5711,6 +5749,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5711
5749
  runtimeDirectives.push(prop);
5712
5750
  if (hasChildren) {
5713
5751
  shouldUseBlock = true;
5752
+ isBlockRequired = true;
5714
5753
  }
5715
5754
  }
5716
5755
  }
@@ -5749,7 +5788,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5749
5788
  patchFlag |= 32;
5750
5789
  }
5751
5790
  }
5752
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
5791
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
5792
+ if (!shouldUseBlock && needsPatch) {
5753
5793
  patchFlag |= 512;
5754
5794
  }
5755
5795
  if (!context.inSSR && propsExpression) {
@@ -5815,7 +5855,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5815
5855
  directives: runtimeDirectives,
5816
5856
  patchFlag,
5817
5857
  dynamicPropNames,
5818
- shouldUseBlock
5858
+ shouldUseBlock,
5859
+ needsPatch,
5860
+ isBlockRequired
5819
5861
  };
5820
5862
  }
5821
5863
  function dedupeProperties(properties) {
@@ -139,6 +139,8 @@ export declare function buildProps(node: ElementNode, context: TransformContext,
139
139
  patchFlag: number;
140
140
  dynamicPropNames: string[];
141
141
  shouldUseBlock: boolean;
142
+ needsPatch: boolean;
143
+ isBlockRequired: boolean;
142
144
  };
143
145
  export declare function buildDirectiveArgs(dir: DirectiveNode, context: TransformContext): ArrayExpression;
144
146
 
@@ -376,6 +378,10 @@ export interface VNodeCall extends Node {
376
378
  patchFlag: PatchFlags | undefined;
377
379
  dynamicProps: string | SimpleExpressionNode | undefined;
378
380
  directives: DirectiveArguments | undefined;
381
+ /** Whether this vnode must be patched if a later transform makes it non-block. */
382
+ needsPatch?: boolean;
383
+ /** Whether a later transform must preserve this vnode as a block. */
384
+ isBlockRequired?: boolean;
379
385
  isBlock: boolean;
380
386
  disableTracking: boolean;
381
387
  isComponent: boolean;
@@ -474,11 +480,24 @@ export interface DirectiveArgumentNode extends ArrayExpression {
474
480
  }
475
481
  export interface RenderSlotCall extends CallExpression {
476
482
  callee: typeof RENDER_SLOT;
477
- arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [
483
+ arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression | '{}'] | [
478
484
  string,
479
485
  string | ExpressionNode,
480
486
  PropsExpression | '{}',
481
- TemplateChildNode[]
487
+ FunctionExpression | string
488
+ ] | [
489
+ string,
490
+ string | ExpressionNode,
491
+ PropsExpression | '{}',
492
+ FunctionExpression | string,
493
+ string
494
+ ] | [
495
+ string,
496
+ string | ExpressionNode,
497
+ PropsExpression | '{}',
498
+ FunctionExpression | string,
499
+ string,
500
+ JSChildNode
482
501
  ];
483
502
  }
484
503
  export type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.5.39
2
+ * @vue/compiler-core v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1819,6 +1819,9 @@ function getUnnormalizedProps(props, callPath = []) {
1819
1819
  return [props, callPath];
1820
1820
  }
1821
1821
  function injectProp(node, prop, context) {
1822
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
1823
+ return;
1824
+ }
1822
1825
  let propsWithInjection;
1823
1826
  let props = node.type === 13 ? node.props : node.arguments[2];
1824
1827
  let callPath = [];
@@ -1876,6 +1879,24 @@ function injectProp(node, prop, context) {
1876
1879
  }
1877
1880
  }
1878
1881
  }
1882
+ function injectSlotKey(node, prop) {
1883
+ var _a, _b, _c;
1884
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
1885
+ return false;
1886
+ }
1887
+ const props = node.arguments[2];
1888
+ if (props && !isString(props)) {
1889
+ const [unnormalizedProps] = getUnnormalizedProps(props);
1890
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
1891
+ return true;
1892
+ }
1893
+ }
1894
+ (_a = node.arguments)[2] || (_a[2] = "{}");
1895
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
1896
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
1897
+ node.arguments[5] = prop.value;
1898
+ return true;
1899
+ }
1879
1900
  function hasProp(prop, props) {
1880
1901
  let result = false;
1881
1902
  if (prop.key.type === 4) {
@@ -4195,6 +4216,7 @@ const transformFor = createStructuralDirectiveTransform(
4195
4216
  node.loc
4196
4217
  );
4197
4218
  return () => {
4219
+ var _a;
4198
4220
  let childBlock;
4199
4221
  const { children } = forNode;
4200
4222
  if ((!!(process.env.NODE_ENV !== "production") || false) && isTemplate) {
@@ -4238,7 +4260,8 @@ const transformFor = createStructuralDirectiveTransform(
4238
4260
  if (isTemplate && keyProperty) {
4239
4261
  injectProp(childBlock, keyProperty, context);
4240
4262
  }
4241
- if (childBlock.isBlock !== !isStableFragment) {
4263
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
4264
+ if (childBlock.isBlock !== shouldUseBlock) {
4242
4265
  if (childBlock.isBlock) {
4243
4266
  removeHelper(OPEN_BLOCK);
4244
4267
  removeHelper(
@@ -4250,12 +4273,15 @@ const transformFor = createStructuralDirectiveTransform(
4250
4273
  );
4251
4274
  }
4252
4275
  }
4253
- childBlock.isBlock = !isStableFragment;
4276
+ childBlock.isBlock = shouldUseBlock;
4254
4277
  if (childBlock.isBlock) {
4255
4278
  helper(OPEN_BLOCK);
4256
4279
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
4257
4280
  } else {
4258
4281
  helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
4282
+ if (childBlock.needsPatch) {
4283
+ childBlock.patchFlag = ((_a = childBlock.patchFlag) != null ? _a : 0) | 512;
4284
+ }
4259
4285
  }
4260
4286
  }
4261
4287
  if (memo) {
@@ -4653,6 +4679,8 @@ const transformElement = (node, context) => {
4653
4679
  let vnodeDynamicProps;
4654
4680
  let dynamicPropNames;
4655
4681
  let vnodeDirectives;
4682
+ let needsPatch = false;
4683
+ let isBlockRequired = false;
4656
4684
  let shouldUseBlock = (
4657
4685
  // dynamic component may resolve to plain elements
4658
4686
  isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
@@ -4672,6 +4700,8 @@ const transformElement = (node, context) => {
4672
4700
  vnodeProps = propsBuildResult.props;
4673
4701
  patchFlag = propsBuildResult.patchFlag;
4674
4702
  dynamicPropNames = propsBuildResult.dynamicPropNames;
4703
+ needsPatch = propsBuildResult.needsPatch;
4704
+ isBlockRequired = propsBuildResult.isBlockRequired;
4675
4705
  const directives = propsBuildResult.directives;
4676
4706
  vnodeDirectives = directives && directives.length ? createArrayExpression(
4677
4707
  directives.map((dir) => buildDirectiveArgs(dir, context))
@@ -4722,7 +4752,7 @@ const transformElement = (node, context) => {
4722
4752
  if (dynamicPropNames && dynamicPropNames.length) {
4723
4753
  vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
4724
4754
  }
4725
- node.codegenNode = createVNodeCall(
4755
+ const vnodeCall = node.codegenNode = createVNodeCall(
4726
4756
  context,
4727
4757
  vnodeTag,
4728
4758
  vnodeProps,
@@ -4735,6 +4765,13 @@ const transformElement = (node, context) => {
4735
4765
  isComponent,
4736
4766
  node.loc
4737
4767
  );
4768
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
4769
+ if (needsPatch) {
4770
+ vnodeCall.needsPatch = true;
4771
+ }
4772
+ if (isBlockRequired) {
4773
+ vnodeCall.isBlockRequired = true;
4774
+ }
4738
4775
  };
4739
4776
  };
4740
4777
  function resolveComponentType(node, context, ssr = false) {
@@ -4786,6 +4823,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4786
4823
  const runtimeDirectives = [];
4787
4824
  const hasChildren = children.length > 0;
4788
4825
  let shouldUseBlock = false;
4826
+ let isBlockRequired = false;
4789
4827
  let patchFlag = 0;
4790
4828
  let hasRef = false;
4791
4829
  let hasClassBinding = false;
@@ -4827,19 +4865,20 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4827
4865
  if (isEventHandler && isReservedProp(name)) {
4828
4866
  hasVnodeHook = true;
4829
4867
  }
4868
+ if (name === "ref") {
4869
+ hasRef = true;
4870
+ }
4830
4871
  if (isEventHandler && value.type === 14) {
4831
4872
  value = value.arguments[0];
4832
4873
  }
4833
4874
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
4834
4875
  return;
4835
4876
  }
4836
- if (name === "ref") {
4837
- hasRef = true;
4838
- } else if (name === "class") {
4877
+ if (name === "class") {
4839
4878
  hasClassBinding = true;
4840
4879
  } else if (name === "style") {
4841
4880
  hasStyleBinding = true;
4842
- } else if (name !== "key" && !dynamicPropNames.includes(name)) {
4881
+ } else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) {
4843
4882
  dynamicPropNames.push(name);
4844
4883
  }
4845
4884
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
@@ -4898,13 +4937,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4898
4937
  if (isVOn && ssr) {
4899
4938
  continue;
4900
4939
  }
4901
- if (
4902
- // #938: elements with dynamic keys should be forced into blocks
4903
- isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
4904
- // before children
4905
- isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
4906
- ) {
4940
+ if (isVBind && isStaticArgOf(arg, "key")) {
4941
+ shouldUseBlock = true;
4942
+ }
4943
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
4907
4944
  shouldUseBlock = true;
4945
+ isBlockRequired = true;
4908
4946
  }
4909
4947
  if (isVBind && isStaticArgOf(arg, "ref")) {
4910
4948
  pushRefVForMarker();
@@ -4987,6 +5025,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4987
5025
  runtimeDirectives.push(prop);
4988
5026
  if (hasChildren) {
4989
5027
  shouldUseBlock = true;
5028
+ isBlockRequired = true;
4990
5029
  }
4991
5030
  }
4992
5031
  }
@@ -5025,7 +5064,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5025
5064
  patchFlag |= 32;
5026
5065
  }
5027
5066
  }
5028
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
5067
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
5068
+ if (!shouldUseBlock && needsPatch) {
5029
5069
  patchFlag |= 512;
5030
5070
  }
5031
5071
  if (!context.inSSR && propsExpression) {
@@ -5091,7 +5131,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5091
5131
  directives: runtimeDirectives,
5092
5132
  patchFlag,
5093
5133
  dynamicPropNames,
5094
- shouldUseBlock
5134
+ shouldUseBlock,
5135
+ needsPatch,
5136
+ isBlockRequired
5095
5137
  };
5096
5138
  }
5097
5139
  function dedupeProperties(properties) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.5.39",
3
+ "version": "3.5.41",
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.29.7",
49
+ "@babel/parser": "^7.29.8",
50
50
  "entities": "^7.0.1",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.1",
53
- "@vue/shared": "3.5.39"
53
+ "@vue/shared": "3.5.41"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/types": "^7.29.7"
56
+ "@babel/types": "^7.29.8"
57
57
  }
58
58
  }