@vue/compiler-core 3.6.0-beta.9 → 3.6.0-rc.10

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.6.0-beta.9
2
+ * @vue/compiler-core v3.6.0-rc.10
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -547,13 +547,14 @@ var Tokenizer = class {
547
547
  }
548
548
  }
549
549
  stateInterpolationOpen(c) {
550
- if (c === this.delimiterOpen[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterOpen.length - 1) {
551
- const start = this.index + 1 - this.delimiterOpen.length;
552
- if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
553
- this.state = 3;
554
- this.sectionStart = start;
555
- } else this.delimiterIndex++;
556
- else if (this.inRCDATA) {
550
+ if (c === this.delimiterOpen[this.delimiterIndex]) {
551
+ if (this.delimiterIndex === this.delimiterOpen.length - 1) {
552
+ const start = this.index + 1 - this.delimiterOpen.length;
553
+ if (start > this.sectionStart) this.cbs.ontext(this.sectionStart, start);
554
+ this.state = 3;
555
+ this.sectionStart = start;
556
+ } else this.delimiterIndex++;
557
+ } else if (this.inRCDATA) {
557
558
  this.state = 32;
558
559
  this.stateInRCDATA(c);
559
560
  } else {
@@ -569,13 +570,14 @@ var Tokenizer = class {
569
570
  }
570
571
  }
571
572
  stateInterpolationClose(c) {
572
- if (c === this.delimiterClose[this.delimiterIndex]) if (this.delimiterIndex === this.delimiterClose.length - 1) {
573
- this.cbs.oninterpolation(this.sectionStart, this.index + 1);
574
- if (this.inRCDATA) this.state = 32;
575
- else this.state = 1;
576
- this.sectionStart = this.index + 1;
577
- } else this.delimiterIndex++;
578
- else {
573
+ if (c === this.delimiterClose[this.delimiterIndex]) {
574
+ if (this.delimiterIndex === this.delimiterClose.length - 1) {
575
+ this.cbs.oninterpolation(this.sectionStart, this.index + 1);
576
+ if (this.inRCDATA) this.state = 32;
577
+ else this.state = 1;
578
+ this.sectionStart = this.index + 1;
579
+ } else this.delimiterIndex++;
580
+ } else {
579
581
  this.state = 3;
580
582
  this.stateInterpolation(c);
581
583
  }
@@ -690,9 +692,10 @@ var Tokenizer = class {
690
692
  this.sectionStart = this.index;
691
693
  if (this.mode === 0) this.state = 6;
692
694
  else if (this.inSFCRoot) this.state = 34;
693
- else if (!this.inXML) if (c === 116) this.state = 30;
694
- else this.state = c === 115 ? 29 : 6;
695
- else this.state = 6;
695
+ else if (!this.inXML) {
696
+ if (c === 116) this.state = 30;
697
+ else this.state = c === 115 ? 29 : 6;
698
+ } else this.state = 6;
696
699
  } else if (c === 47) this.state = 8;
697
700
  else {
698
701
  this.state = 1;
@@ -1045,9 +1048,7 @@ var Tokenizer = class {
1045
1048
  case 24:
1046
1049
  this.stateInProcessingInstruction(c);
1047
1050
  break;
1048
- case 33:
1049
- this.stateInEntity();
1050
- break;
1051
+ case 33: this.stateInEntity();
1051
1052
  }
1052
1053
  this.index++;
1053
1054
  }
@@ -1076,9 +1077,10 @@ var Tokenizer = class {
1076
1077
  handleTrailingData() {
1077
1078
  const endIndex = this.buffer.length;
1078
1079
  if (this.sectionStart >= endIndex) return;
1079
- if (this.state === 28) if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
1080
- else this.cbs.oncomment(this.sectionStart, endIndex);
1081
- else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) {} else this.cbs.ontext(this.sectionStart, endIndex);
1080
+ if (this.state === 28) {
1081
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex);
1082
+ else this.cbs.oncomment(this.sectionStart, endIndex);
1083
+ } else if (this.state === 6 || this.state === 11 || this.state === 18 || this.state === 17 || this.state === 12 || this.state === 13 || this.state === 14 || this.state === 15 || this.state === 16 || this.state === 20 || this.state === 19 || this.state === 21 || this.state === 9) {} else this.cbs.ontext(this.sectionStart, endIndex);
1082
1084
  }
1083
1085
  emitCodePoint(cp, consumed) {}
1084
1086
  };
@@ -1411,9 +1413,7 @@ function extractIdentifiers(param, nodes = []) {
1411
1413
  case "RestElement":
1412
1414
  extractIdentifiers(param.argument, nodes);
1413
1415
  break;
1414
- case "AssignmentPattern":
1415
- extractIdentifiers(param.left, nodes);
1416
- break;
1416
+ case "AssignmentPattern": extractIdentifiers(param.left, nodes);
1417
1417
  }
1418
1418
  return nodes;
1419
1419
  }
@@ -1549,12 +1549,10 @@ const isMemberExpressionBrowser = (exp) => {
1549
1549
  if (!--currentOpenParensCount) state = stateStack.pop();
1550
1550
  }
1551
1551
  break;
1552
- case 3:
1553
- if (char === currentStringType) {
1554
- state = stateStack.pop();
1555
- currentStringType = null;
1556
- }
1557
- break;
1552
+ case 3: if (char === currentStringType) {
1553
+ state = stateStack.pop();
1554
+ currentStringType = null;
1555
+ }
1558
1556
  }
1559
1557
  }
1560
1558
  return !currentOpenBracketCount && !currentOpenParensCount;
@@ -1625,7 +1623,7 @@ function isTemplateNode(node) {
1625
1623
  function isSlotOutlet(node) {
1626
1624
  return node.type === 1 && node.tagType === 2;
1627
1625
  }
1628
- const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
1626
+ const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
1629
1627
  function getUnnormalizedProps(props, callPath = []) {
1630
1628
  if (props && !isString(props) && props.type === 14) {
1631
1629
  const callee = props.callee;
@@ -1634,6 +1632,7 @@ function getUnnormalizedProps(props, callPath = []) {
1634
1632
  return [props, callPath];
1635
1633
  }
1636
1634
  function injectProp(node, prop, context) {
1635
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
1637
1636
  let propsWithInjection;
1638
1637
  /**
1639
1638
  * 1. mergeProps(...)
@@ -1667,11 +1666,26 @@ function injectProp(node, prop, context) {
1667
1666
  propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
1668
1667
  if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) parentCall = callPath[callPath.length - 2];
1669
1668
  }
1670
- if (node.type === 13) if (parentCall) parentCall.arguments[0] = propsWithInjection;
1671
- else node.props = propsWithInjection;
1672
- else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1669
+ if (node.type === 13) {
1670
+ if (parentCall) parentCall.arguments[0] = propsWithInjection;
1671
+ else node.props = propsWithInjection;
1672
+ } else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1673
1673
  else node.arguments[2] = propsWithInjection;
1674
1674
  }
1675
+ function injectSlotKey(node, prop) {
1676
+ var _node$arguments, _node$arguments2, _node$arguments3;
1677
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
1678
+ const props = node.arguments[2];
1679
+ if (props && !isString(props)) {
1680
+ const [unnormalizedProps] = getUnnormalizedProps(props);
1681
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
1682
+ }
1683
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
1684
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
1685
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
1686
+ node.arguments[5] = prop.value;
1687
+ return true;
1688
+ }
1675
1689
  function hasProp(prop, props) {
1676
1690
  let result = false;
1677
1691
  if (prop.key.type === 4) {
@@ -1972,10 +1986,7 @@ const tokenizer = new Tokenizer(stack, {
1972
1986
  case 18:
1973
1987
  case 19:
1974
1988
  case 20:
1975
- case 21:
1976
- emitError(9, end);
1977
- break;
1978
- default: break;
1989
+ case 21: emitError(9, end);
1979
1990
  }
1980
1991
  for (let index = 0; index < stack.length; index++) {
1981
1992
  onCloseTag(stack[index], end - 1);
@@ -1983,7 +1994,7 @@ const tokenizer = new Tokenizer(stack, {
1983
1994
  }
1984
1995
  },
1985
1996
  oncdata(start, end) {
1986
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
1997
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
1987
1998
  else emitError(1, start - 9);
1988
1999
  },
1989
2000
  onprocessinginstruction(start) {
@@ -2125,7 +2136,7 @@ function backTrack(index, c) {
2125
2136
  while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
2126
2137
  return i;
2127
2138
  }
2128
- const specialTemplateDir = new Set([
2139
+ const specialTemplateDir = /* @__PURE__ */ new Set([
2129
2140
  "if",
2130
2141
  "else",
2131
2142
  "else-if",
@@ -2161,16 +2172,18 @@ function condenseWhitespace(nodes) {
2161
2172
  let removedWhitespace = false;
2162
2173
  for (let i = 0; i < nodes.length; i++) {
2163
2174
  const node = nodes[i];
2164
- if (node.type === 2) if (!inPre) {
2165
- if (isAllWhitespace(node.content)) {
2166
- const prev = nodes[i - 1] && nodes[i - 1].type;
2167
- const next = nodes[i + 1] && nodes[i + 1].type;
2168
- if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2169
- removedWhitespace = true;
2170
- nodes[i] = null;
2171
- } else node.content = " ";
2172
- } else if (shouldCondense) node.content = condense(node.content);
2173
- } else node.content = node.content.replace(windowsNewlineRE, "\n");
2175
+ if (node.type === 2) {
2176
+ if (!inPre) {
2177
+ if (isAllWhitespace(node.content)) {
2178
+ const prev = nodes[i - 1] && nodes[i - 1].type;
2179
+ const next = nodes[i + 1] && nodes[i + 1].type;
2180
+ if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2181
+ removedWhitespace = true;
2182
+ nodes[i] = null;
2183
+ } else node.content = " ";
2184
+ } else if (shouldCondense) node.content = condense(node.content);
2185
+ } else node.content = node.content.replace(windowsNewlineRE, "\n");
2186
+ }
2174
2187
  }
2175
2188
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2176
2189
  }
@@ -2435,7 +2448,7 @@ function getConstantType(node, context) {
2435
2448
  return 0;
2436
2449
  }
2437
2450
  }
2438
- const allowHoistedHelperSet = new Set([
2451
+ const allowHoistedHelperSet = /* @__PURE__ */ new Set([
2439
2452
  NORMALIZE_CLASS,
2440
2453
  NORMALIZE_STYLE,
2441
2454
  NORMALIZE_PROPS,
@@ -2512,8 +2525,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2512
2525
  imports: [],
2513
2526
  cached: [],
2514
2527
  constantCache: /* @__PURE__ */ new WeakMap(),
2528
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
2515
2529
  temps: 0,
2516
2530
  identifiers: Object.create(null),
2531
+ identifierScopes: Object.create(null),
2517
2532
  scopes: {
2518
2533
  vFor: 0,
2519
2534
  vSlot: 0,
@@ -2567,8 +2582,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2567
2582
  context.parent.children.splice(removalIndex, 1);
2568
2583
  },
2569
2584
  onNodeRemoved: NOOP,
2570
- addIdentifiers(exp) {},
2585
+ addIdentifiers(exp, type = "local") {},
2571
2586
  removeIdentifiers(exp) {},
2587
+ isSlotScopeIdentifier(name) {
2588
+ const scopes = context.identifierScopes[name];
2589
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
2590
+ },
2572
2591
  hoist(exp) {
2573
2592
  if (isString(exp)) exp = createSimpleExpression(exp);
2574
2593
  context.hoists.push(exp);
@@ -2590,7 +2609,7 @@ function transform(root, options) {
2590
2609
  traverseNode(root, context);
2591
2610
  if (options.hoistStatic) cacheStatic(root, context);
2592
2611
  if (!options.ssr) createRootCodegen(root, context);
2593
- root.helpers = new Set([...context.helpers.keys()]);
2612
+ root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
2594
2613
  root.components = [...context.components];
2595
2614
  root.directives = [...context.directives];
2596
2615
  root.imports = context.imports;
@@ -2637,8 +2656,10 @@ function traverseNode(node, context) {
2637
2656
  const exitFns = [];
2638
2657
  for (let i = 0; i < nodeTransforms.length; i++) {
2639
2658
  const onExit = nodeTransforms[i](node, context);
2640
- if (onExit) if (isArray(onExit)) exitFns.push(...onExit);
2641
- else exitFns.push(onExit);
2659
+ if (onExit) {
2660
+ if (isArray(onExit)) exitFns.push(...onExit);
2661
+ else exitFns.push(onExit);
2662
+ }
2642
2663
  if (!context.currentNode) return;
2643
2664
  else node = context.currentNode;
2644
2665
  }
@@ -2655,9 +2676,7 @@ function traverseNode(node, context) {
2655
2676
  case 10:
2656
2677
  case 11:
2657
2678
  case 1:
2658
- case 0:
2659
- traverseChildren(node, context);
2660
- break;
2679
+ case 0: traverseChildren(node, context);
2661
2680
  }
2662
2681
  context.currentNode = node;
2663
2682
  let i = exitFns.length;
@@ -2863,10 +2882,12 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2863
2882
  if (isString(node)) push(node, -3);
2864
2883
  else if (isArray(node)) genNodeListAsArray(node, context);
2865
2884
  else genNode(node, context);
2866
- if (i < nodes.length - 1) if (multilines) {
2867
- comma && push(",");
2868
- newline();
2869
- } else comma && push(", ");
2885
+ if (i < nodes.length - 1) {
2886
+ if (multilines) {
2887
+ comma && push(",");
2888
+ newline();
2889
+ } else comma && push(", ");
2890
+ }
2870
2891
  }
2871
2892
  }
2872
2893
  function genNode(node, context) {
@@ -2932,6 +2953,7 @@ function genNode(node, context) {
2932
2953
  case 24: break;
2933
2954
  case 25: break;
2934
2955
  case 26: break;
2956
+ /* v8 ignore start */
2935
2957
  case 10: break;
2936
2958
  default: if (!!(process.env.NODE_ENV !== "production")) {
2937
2959
  assert(false, `unhandled codegen node type: ${node.type}`);
@@ -2978,9 +3000,12 @@ function genVNodeCall(node, context) {
2978
3000
  const { push, helper, pure } = context;
2979
3001
  const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
2980
3002
  let patchFlagString;
2981
- if (patchFlag) if (!!(process.env.NODE_ENV !== "production")) if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
2982
- else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
2983
- else patchFlagString = String(patchFlag);
3003
+ if (patchFlag) {
3004
+ if (!!(process.env.NODE_ENV !== "production")) {
3005
+ if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
3006
+ else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
3007
+ } else patchFlagString = String(patchFlag);
3008
+ }
2984
3009
  if (directives) push(helper(WITH_DIRECTIVES) + `(`);
2985
3010
  if (isBlock) push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
2986
3011
  if (pure) push(PURE_ANNOTATION);
@@ -3142,7 +3167,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
3142
3167
  }
3143
3168
  //#endregion
3144
3169
  //#region packages/compiler-core/src/transforms/transformExpression.ts
3145
- const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
3170
+ const isLiteralWhitelisted = /*@__PURE__*/ makeMap("true,false,null,this");
3146
3171
  const transformExpression = (node, context) => {
3147
3172
  if (node.type === 5) node.content = processExpression(node.content, context);
3148
3173
  else if (node.type === 1) {
@@ -3152,7 +3177,7 @@ const transformExpression = (node, context) => {
3152
3177
  if (dir.type === 7 && dir.name !== "for") {
3153
3178
  const exp = dir.exp;
3154
3179
  const arg = dir.arg;
3155
- if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
3180
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && context.vForMemoKeyedNodes.has(node) && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
3156
3181
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3157
3182
  }
3158
3183
  }
@@ -3255,16 +3280,17 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
3255
3280
  const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
3256
3281
  const { children } = branch;
3257
3282
  const firstChild = children[0];
3258
- if (children.length !== 1 || firstChild.type !== 1) if (children.length === 1 && firstChild.type === 11) {
3259
- const vnodeCall = firstChild.codegenNode;
3260
- injectProp(vnodeCall, keyProperty, context);
3261
- return vnodeCall;
3283
+ if (children.length !== 1 || firstChild.type !== 1) {
3284
+ if (children.length === 1 && firstChild.type === 11) {
3285
+ const vnodeCall = firstChild.codegenNode;
3286
+ injectProp(vnodeCall, keyProperty, context);
3287
+ return vnodeCall;
3288
+ } else {
3289
+ let patchFlag = 64;
3290
+ if (!!(process.env.NODE_ENV !== "production") && !branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
3291
+ return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
3292
+ }
3262
3293
  } else {
3263
- let patchFlag = 64;
3264
- if (!!(process.env.NODE_ENV !== "production") && !branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
3265
- return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
3266
- }
3267
- else {
3268
3294
  const ret = firstChild.codegenNode;
3269
3295
  const vnodeCall = getMemoedVNodeCall(ret);
3270
3296
  if (vnodeCall.type === 13) convertToBlock(vnodeCall, context);
@@ -3285,9 +3311,10 @@ function isSameKey(a, b) {
3285
3311
  return true;
3286
3312
  }
3287
3313
  function getParentCondition(node) {
3288
- while (true) if (node.type === 19) if (node.alternate.type === 19) node = node.alternate;
3289
- else return node;
3290
- else if (node.type === 20) node = node.value;
3314
+ while (true) if (node.type === 19) {
3315
+ if (node.alternate.type === 19) node = node.alternate;
3316
+ else return node;
3317
+ } else if (node.type === 20) node = node.value;
3291
3318
  }
3292
3319
  //#endregion
3293
3320
  //#region packages/compiler-core/src/transforms/vFor.ts
@@ -3298,10 +3325,9 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3298
3325
  const isTemplate = isTemplateNode(node);
3299
3326
  const memo = findDir(node, "memo");
3300
3327
  const keyProp = findProp(node, `key`, false, true);
3301
- const isDirKey = keyProp && keyProp.type === 7;
3328
+ keyProp && keyProp.type;
3302
3329
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
3303
- if (memo && keyExp && isDirKey) {}
3304
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
3330
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
3305
3331
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
3306
3332
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
3307
3333
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
@@ -3326,15 +3352,24 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3326
3352
  else {
3327
3353
  childBlock = children[0].codegenNode;
3328
3354
  if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
3329
- if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
3330
- removeHelper(OPEN_BLOCK);
3331
- removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3332
- } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3333
- childBlock.isBlock = !isStableFragment;
3355
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
3356
+ if (childBlock.isBlock !== shouldUseBlock) {
3357
+ if (childBlock.isBlock) {
3358
+ removeHelper(OPEN_BLOCK);
3359
+ removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3360
+ } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3361
+ }
3362
+ childBlock.isBlock = shouldUseBlock;
3334
3363
  if (childBlock.isBlock) {
3335
3364
  helper(OPEN_BLOCK);
3336
3365
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3337
- } else helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3366
+ } else {
3367
+ helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3368
+ if (childBlock.needsPatch) {
3369
+ var _childBlock$patchFlag;
3370
+ childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
3371
+ }
3372
+ }
3338
3373
  }
3339
3374
  if (memo) {
3340
3375
  const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
@@ -3527,8 +3562,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3527
3562
  return createObjectProperty(`default`, fn);
3528
3563
  };
3529
3564
  if (!hasTemplateSlots) slotsProperties.push(buildDefaultSlotProperty(void 0, children));
3530
- else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
3531
- else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
3565
+ else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) {
3566
+ if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
3567
+ else slotsProperties.push(buildDefaultSlotProperty(void 0, implicitDefaultChildren));
3568
+ }
3532
3569
  }
3533
3570
  const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
3534
3571
  let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`, createSimpleExpression(slotFlag + (!!(process.env.NODE_ENV !== "production") ? ` /* ${slotFlagsText[slotFlag]} */` : ``), false))), loc);
@@ -3554,10 +3591,7 @@ function hasForwardedSlots(children) {
3554
3591
  if (hasForwardedSlots(child.branches)) return true;
3555
3592
  break;
3556
3593
  case 10:
3557
- case 11:
3558
- if (hasForwardedSlots(child.children)) return true;
3559
- break;
3560
- default: break;
3594
+ case 11: if (hasForwardedSlots(child.children)) return true;
3561
3595
  }
3562
3596
  }
3563
3597
  return false;
@@ -3579,12 +3613,16 @@ const transformElement = (node, context) => {
3579
3613
  let vnodeDynamicProps;
3580
3614
  let dynamicPropNames;
3581
3615
  let vnodeDirectives;
3616
+ let needsPatch = false;
3617
+ let isBlockRequired = false;
3582
3618
  let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
3583
3619
  if (props.length > 0) {
3584
3620
  const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
3585
3621
  vnodeProps = propsBuildResult.props;
3586
3622
  patchFlag = propsBuildResult.patchFlag;
3587
3623
  dynamicPropNames = propsBuildResult.dynamicPropNames;
3624
+ needsPatch = propsBuildResult.needsPatch;
3625
+ isBlockRequired = propsBuildResult.isBlockRequired;
3588
3626
  const directives = propsBuildResult.directives;
3589
3627
  vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
3590
3628
  if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
@@ -3613,7 +3651,10 @@ const transformElement = (node, context) => {
3613
3651
  } else vnodeChildren = node.children;
3614
3652
  }
3615
3653
  if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
3616
- node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3654
+ const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3655
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
3656
+ if (needsPatch) vnodeCall.needsPatch = true;
3657
+ if (isBlockRequired) vnodeCall.isBlockRequired = true;
3617
3658
  };
3618
3659
  };
3619
3660
  function resolveComponentType(node, context, ssr = false) {
@@ -3647,6 +3688,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3647
3688
  const runtimeDirectives = [];
3648
3689
  const hasChildren = children.length > 0;
3649
3690
  let shouldUseBlock = false;
3691
+ let isBlockRequired = false;
3650
3692
  let patchFlag = 0;
3651
3693
  let hasRef = false;
3652
3694
  let hasClassBinding = false;
@@ -3671,12 +3713,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3671
3713
  const isEventHandler = isOn(name);
3672
3714
  if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
3673
3715
  if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
3716
+ if (name === "ref") hasRef = true;
3674
3717
  if (isEventHandler && value.type === 14) value = value.arguments[0];
3675
3718
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
3676
- if (name === "ref") hasRef = true;
3677
- else if (name === "class") hasClassBinding = true;
3719
+ if (name === "class") hasClassBinding = true;
3678
3720
  else if (name === "style") hasStyleBinding = true;
3679
- else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3721
+ else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3680
3722
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3681
3723
  } else hasDynamicKeys = true;
3682
3724
  };
@@ -3702,35 +3744,40 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3702
3744
  if (name === "once" || name === "memo") continue;
3703
3745
  if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
3704
3746
  if (isVOn && ssr) continue;
3705
- if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) shouldUseBlock = true;
3747
+ if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
3748
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
3749
+ shouldUseBlock = true;
3750
+ isBlockRequired = true;
3751
+ }
3706
3752
  if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
3707
3753
  if (!arg && (isVBind || isVOn)) {
3708
3754
  hasDynamicKeys = true;
3709
- if (exp) if (isVBind) {
3710
- pushMergeArg();
3711
- if (!!(process.env.NODE_ENV !== "production")) {
3712
- if (mergeArgs.some((arg) => {
3713
- if (arg.type === 15) return arg.properties.some(({ key }) => {
3714
- if (key.type !== 4 || !key.isStatic) return true;
3715
- return key.content !== "class" && key.content !== "style" && !isOn(key.content);
3716
- });
3717
- else return true;
3718
- })) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
3719
- }
3720
- if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
3721
- mergeArgs.unshift(exp);
3722
- continue;
3723
- }
3724
- pushRefVForMarker();
3725
- pushMergeArg();
3726
- mergeArgs.push(exp);
3727
- } else pushMergeArg({
3728
- type: 14,
3729
- loc,
3730
- callee: context.helper(TO_HANDLERS),
3731
- arguments: isComponent ? [exp] : [exp, `true`]
3732
- });
3733
- else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
3755
+ if (exp) {
3756
+ if (isVBind) {
3757
+ pushMergeArg();
3758
+ if (!!(process.env.NODE_ENV !== "production")) {
3759
+ if (mergeArgs.some((arg) => {
3760
+ if (arg.type === 15) return arg.properties.some(({ key }) => {
3761
+ if (key.type !== 4 || !key.isStatic) return true;
3762
+ return key.content !== "class" && key.content !== "style" && !isOn(key.content);
3763
+ });
3764
+ else return true;
3765
+ })) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
3766
+ }
3767
+ if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
3768
+ mergeArgs.unshift(exp);
3769
+ continue;
3770
+ }
3771
+ pushRefVForMarker();
3772
+ pushMergeArg();
3773
+ mergeArgs.push(exp);
3774
+ } else pushMergeArg({
3775
+ type: 14,
3776
+ loc,
3777
+ callee: context.helper(TO_HANDLERS),
3778
+ arguments: isComponent ? [exp] : [exp, `true`]
3779
+ });
3780
+ } else context.onError(createCompilerError(isVBind ? 34 : 35, loc));
3734
3781
  continue;
3735
3782
  }
3736
3783
  if (isVBind && modifiers.some((mod) => mod.content === "prop")) patchFlag |= 32;
@@ -3746,7 +3793,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3746
3793
  }
3747
3794
  } else if (!isBuiltInDirective(name)) {
3748
3795
  runtimeDirectives.push(prop);
3749
- if (hasChildren) shouldUseBlock = true;
3796
+ if (hasChildren) {
3797
+ shouldUseBlock = true;
3798
+ isBlockRequired = true;
3799
+ }
3750
3800
  }
3751
3801
  }
3752
3802
  }
@@ -3763,7 +3813,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3763
3813
  if (dynamicPropNames.length) patchFlag |= 8;
3764
3814
  if (hasHydrationEventBinding) patchFlag |= 32;
3765
3815
  }
3766
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) patchFlag |= 512;
3816
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
3817
+ if (!shouldUseBlock && needsPatch) patchFlag |= 512;
3767
3818
  if (!context.inSSR && propsExpression) switch (propsExpression.type) {
3768
3819
  case 15:
3769
3820
  let classKeyIndex = -1;
@@ -3784,16 +3835,16 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3784
3835
  } else propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
3785
3836
  break;
3786
3837
  case 14: break;
3787
- default:
3788
- propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3789
- break;
3838
+ default: propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3790
3839
  }
3791
3840
  return {
3792
3841
  props: propsExpression,
3793
3842
  directives: runtimeDirectives,
3794
3843
  patchFlag,
3795
3844
  dynamicPropNames,
3796
- shouldUseBlock
3845
+ shouldUseBlock,
3846
+ needsPatch,
3847
+ isBlockRequired
3797
3848
  };
3798
3849
  }
3799
3850
  function dedupeProperties(properties) {
@@ -3890,10 +3941,12 @@ function processSlotOutlet(node, context) {
3890
3941
  for (let i = 0; i < node.props.length; i++) {
3891
3942
  const p = node.props[i];
3892
3943
  if (p.type === 6) {
3893
- if (p.value) if (p.name === "name") slotName = JSON.stringify(p.value.content);
3894
- else {
3895
- p.name = camelize(p.name);
3896
- nonNameProps.push(p);
3944
+ if (p.value) {
3945
+ if (p.name === "name") slotName = JSON.stringify(p.value.content);
3946
+ else {
3947
+ p.name = camelize(p.name);
3948
+ nonNameProps.push(p);
3949
+ }
3897
3950
  }
3898
3951
  } else if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
3899
3952
  if (p.exp) slotName = p.exp;
@@ -3919,17 +3972,18 @@ const transformOn = (dir, node, context, augmentor) => {
3919
3972
  const { loc, modifiers, arg } = dir;
3920
3973
  if (!dir.exp && !modifiers.length) context.onError(createCompilerError(35, loc));
3921
3974
  let eventName;
3922
- if (arg.type === 4) if (arg.isStatic) {
3923
- let rawName = arg.content;
3924
- if (!!(process.env.NODE_ENV !== "production") && rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
3925
- if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
3926
- eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
3927
- } else eventName = createCompoundExpression([
3928
- `${context.helperString(TO_HANDLER_KEY)}(`,
3929
- arg,
3930
- `)`
3931
- ]);
3932
- else {
3975
+ if (arg.type === 4) {
3976
+ if (arg.isStatic) {
3977
+ let rawName = arg.content;
3978
+ if (!!(process.env.NODE_ENV !== "production") && rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
3979
+ if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
3980
+ eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
3981
+ } else eventName = createCompoundExpression([
3982
+ `${context.helperString(TO_HANDLER_KEY)}(`,
3983
+ arg,
3984
+ `)`
3985
+ ]);
3986
+ } else {
3933
3987
  eventName = arg;
3934
3988
  eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
3935
3989
  eventName.children.push(`)`);
@@ -3965,11 +4019,14 @@ const transformBind = (dir, _node, context) => {
3965
4019
  arg.children.unshift(`(`);
3966
4020
  arg.children.push(`) || ""`);
3967
4021
  } else if (!arg.isStatic) arg.content = arg.content ? `${arg.content} || ""` : `""`;
3968
- if (modifiers.some((mod) => mod.content === "camel")) if (arg.type === 4) if (arg.isStatic) arg.content = camelize(arg.content);
3969
- else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
3970
- else {
3971
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
3972
- arg.children.push(`)`);
4022
+ if (modifiers.some((mod) => mod.content === "camel")) {
4023
+ if (arg.type === 4) {
4024
+ if (arg.isStatic) arg.content = camelize(arg.content);
4025
+ else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
4026
+ } else {
4027
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
4028
+ arg.children.push(`)`);
4029
+ }
3973
4030
  }
3974
4031
  if (!context.inSSR) {
3975
4032
  if (modifiers.some((mod) => mod.content === "prop")) injectPrefix(arg, ".");
@@ -3978,9 +4035,10 @@ const transformBind = (dir, _node, context) => {
3978
4035
  return { props: [createObjectProperty(arg, exp)] };
3979
4036
  };
3980
4037
  const injectPrefix = (arg, prefix) => {
3981
- if (arg.type === 4) if (arg.isStatic) arg.content = prefix + arg.content;
3982
- else arg.content = `\`${prefix}\${${arg.content}}\``;
3983
- else {
4038
+ if (arg.type === 4) {
4039
+ if (arg.isStatic) arg.content = prefix + arg.content;
4040
+ else arg.content = `\`${prefix}\${${arg.content}}\``;
4041
+ } else {
3984
4042
  arg.children.unshift(`'${prefix}' + (`);
3985
4043
  arg.children.push(`)`);
3986
4044
  }
@@ -4101,7 +4159,7 @@ function rewriteFilter(node, context) {
4101
4159
  const child = node.children[i];
4102
4160
  if (typeof child !== "object") continue;
4103
4161
  if (child.type === 4) parseFilter(child, context);
4104
- else if (child.type === 8) rewriteFilter(node, context);
4162
+ else if (child.type === 8) rewriteFilter(child, context);
4105
4163
  else if (child.type === 5) rewriteFilter(child.content, context);
4106
4164
  }
4107
4165
  }
@@ -4127,11 +4185,12 @@ function parseFilter(node, context) {
4127
4185
  if (c === 96 && prev !== 92) inTemplateString = false;
4128
4186
  } else if (inRegex) {
4129
4187
  if (c === 47 && prev !== 92) inRegex = false;
4130
- } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) if (expression === void 0) {
4131
- lastFilterIndex = i + 1;
4132
- expression = exp.slice(0, i).trim();
4133
- } else pushFilter();
4134
- else {
4188
+ } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
4189
+ if (expression === void 0) {
4190
+ lastFilterIndex = i + 1;
4191
+ expression = exp.slice(0, i).trim();
4192
+ } else pushFilter();
4193
+ } else {
4135
4194
  switch (c) {
4136
4195
  case 34:
4137
4196
  inDouble = true;
@@ -4157,9 +4216,7 @@ function parseFilter(node, context) {
4157
4216
  case 123:
4158
4217
  curly++;
4159
4218
  break;
4160
- case 125:
4161
- curly--;
4162
- break;
4219
+ case 125: curly--;
4163
4220
  }
4164
4221
  if (c === 47) {
4165
4222
  let j = i - 1;