@vue/compiler-core 3.6.0-rc.1 → 3.6.0-rc.11

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-rc.1
2
+ * @vue/compiler-core v3.6.0-rc.11
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;
@@ -1668,9 +1666,10 @@ function injectProp(node, prop, context) {
1668
1666
  propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [createObjectExpression([prop]), props]);
1669
1667
  if (parentCall && parentCall.callee === GUARD_REACTIVE_PROPS) parentCall = callPath[callPath.length - 2];
1670
1668
  }
1671
- if (node.type === 13) if (parentCall) parentCall.arguments[0] = propsWithInjection;
1672
- else node.props = propsWithInjection;
1673
- 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;
1674
1673
  else node.arguments[2] = propsWithInjection;
1675
1674
  }
1676
1675
  function injectSlotKey(node, prop) {
@@ -1987,10 +1986,7 @@ const tokenizer = new Tokenizer(stack, {
1987
1986
  case 18:
1988
1987
  case 19:
1989
1988
  case 20:
1990
- case 21:
1991
- emitError(9, end);
1992
- break;
1993
- default: break;
1989
+ case 21: emitError(9, end);
1994
1990
  }
1995
1991
  for (let index = 0; index < stack.length; index++) {
1996
1992
  onCloseTag(stack[index], end - 1);
@@ -2140,7 +2136,7 @@ function backTrack(index, c) {
2140
2136
  while (currentInput.charCodeAt(i) !== c && i >= 0) i--;
2141
2137
  return i;
2142
2138
  }
2143
- const specialTemplateDir = new Set([
2139
+ const specialTemplateDir = /* @__PURE__ */ new Set([
2144
2140
  "if",
2145
2141
  "else",
2146
2142
  "else-if",
@@ -2176,16 +2172,18 @@ function condenseWhitespace(nodes) {
2176
2172
  let removedWhitespace = false;
2177
2173
  for (let i = 0; i < nodes.length; i++) {
2178
2174
  const node = nodes[i];
2179
- if (node.type === 2) if (!inPre) {
2180
- if (isAllWhitespace(node.content)) {
2181
- const prev = nodes[i - 1] && nodes[i - 1].type;
2182
- const next = nodes[i + 1] && nodes[i + 1].type;
2183
- if (!prev || !next || shouldCondense && (prev === 3 && (next === 3 || next === 1) || prev === 1 && (next === 3 || next === 1 && hasNewlineChar(node.content)))) {
2184
- removedWhitespace = true;
2185
- nodes[i] = null;
2186
- } else node.content = " ";
2187
- } else if (shouldCondense) node.content = condense(node.content);
2188
- } 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
+ }
2189
2187
  }
2190
2188
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
2191
2189
  }
@@ -2450,7 +2448,7 @@ function getConstantType(node, context) {
2450
2448
  return 0;
2451
2449
  }
2452
2450
  }
2453
- const allowHoistedHelperSet = new Set([
2451
+ const allowHoistedHelperSet = /* @__PURE__ */ new Set([
2454
2452
  NORMALIZE_CLASS,
2455
2453
  NORMALIZE_STYLE,
2456
2454
  NORMALIZE_PROPS,
@@ -2494,7 +2492,7 @@ function getSelfName(filename) {
2494
2492
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
2495
2493
  return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
2496
2494
  }
2497
- function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, eventDelegation = true, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
2495
+ function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
2498
2496
  const context = {
2499
2497
  filename,
2500
2498
  selfName: getSelfName(filename),
@@ -2516,7 +2514,6 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2516
2514
  bindingMetadata,
2517
2515
  inline,
2518
2516
  isTS,
2519
- eventDelegation,
2520
2517
  onError,
2521
2518
  onWarn,
2522
2519
  compatConfig,
@@ -2612,7 +2609,7 @@ function transform(root, options) {
2612
2609
  traverseNode(root, context);
2613
2610
  if (options.hoistStatic) cacheStatic(root, context);
2614
2611
  if (!options.ssr) createRootCodegen(root, context);
2615
- root.helpers = new Set([...context.helpers.keys()]);
2612
+ root.helpers = /* @__PURE__ */ new Set([...context.helpers.keys()]);
2616
2613
  root.components = [...context.components];
2617
2614
  root.directives = [...context.directives];
2618
2615
  root.imports = context.imports;
@@ -2659,8 +2656,10 @@ function traverseNode(node, context) {
2659
2656
  const exitFns = [];
2660
2657
  for (let i = 0; i < nodeTransforms.length; i++) {
2661
2658
  const onExit = nodeTransforms[i](node, context);
2662
- if (onExit) if (isArray(onExit)) exitFns.push(...onExit);
2663
- else exitFns.push(onExit);
2659
+ if (onExit) {
2660
+ if (isArray(onExit)) exitFns.push(...onExit);
2661
+ else exitFns.push(onExit);
2662
+ }
2664
2663
  if (!context.currentNode) return;
2665
2664
  else node = context.currentNode;
2666
2665
  }
@@ -2677,9 +2676,7 @@ function traverseNode(node, context) {
2677
2676
  case 10:
2678
2677
  case 11:
2679
2678
  case 1:
2680
- case 0:
2681
- traverseChildren(node, context);
2682
- break;
2679
+ case 0: traverseChildren(node, context);
2683
2680
  }
2684
2681
  context.currentNode = node;
2685
2682
  let i = exitFns.length;
@@ -2885,10 +2882,12 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
2885
2882
  if (isString(node)) push(node, -3);
2886
2883
  else if (isArray(node)) genNodeListAsArray(node, context);
2887
2884
  else genNode(node, context);
2888
- if (i < nodes.length - 1) if (multilines) {
2889
- comma && push(",");
2890
- newline();
2891
- } else comma && push(", ");
2885
+ if (i < nodes.length - 1) {
2886
+ if (multilines) {
2887
+ comma && push(",");
2888
+ newline();
2889
+ } else comma && push(", ");
2890
+ }
2892
2891
  }
2893
2892
  }
2894
2893
  function genNode(node, context) {
@@ -3001,9 +3000,12 @@ function genVNodeCall(node, context) {
3001
3000
  const { push, helper, pure } = context;
3002
3001
  const { tag, props, children, patchFlag, dynamicProps, directives, isBlock, disableTracking, isComponent } = node;
3003
3002
  let patchFlagString;
3004
- if (patchFlag) if (!!(process.env.NODE_ENV !== "production")) if (patchFlag < 0) patchFlagString = patchFlag + ` /* ${PatchFlagNames[patchFlag]} */`;
3005
- else patchFlagString = patchFlag + ` /* ${Object.keys(PatchFlagNames).map(Number).filter((n) => n > 0 && patchFlag & n).map((n) => PatchFlagNames[n]).join(`, `)} */`;
3006
- 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
+ }
3007
3009
  if (directives) push(helper(WITH_DIRECTIVES) + `(`);
3008
3010
  if (isBlock) push(`(${helper(OPEN_BLOCK)}(${disableTracking ? `true` : ``}), `);
3009
3011
  if (pure) push(PURE_ANNOTATION);
@@ -3165,7 +3167,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
3165
3167
  }
3166
3168
  //#endregion
3167
3169
  //#region packages/compiler-core/src/transforms/transformExpression.ts
3168
- const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
3170
+ const isLiteralWhitelisted = /*@__PURE__*/ makeMap("true,false,null,this");
3169
3171
  const transformExpression = (node, context) => {
3170
3172
  if (node.type === 5) node.content = processExpression(node.content, context);
3171
3173
  else if (node.type === 1) {
@@ -3278,16 +3280,17 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
3278
3280
  const keyProperty = createObjectProperty(`key`, createSimpleExpression(`${keyIndex}`, false, locStub, 2));
3279
3281
  const { children } = branch;
3280
3282
  const firstChild = children[0];
3281
- if (children.length !== 1 || firstChild.type !== 1) if (children.length === 1 && firstChild.type === 11) {
3282
- const vnodeCall = firstChild.codegenNode;
3283
- injectProp(vnodeCall, keyProperty, context);
3284
- 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
+ }
3285
3293
  } else {
3286
- let patchFlag = 64;
3287
- if (!!(process.env.NODE_ENV !== "production") && !branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) patchFlag |= 2048;
3288
- return createVNodeCall(context, helper(FRAGMENT), createObjectExpression([keyProperty]), children, patchFlag, void 0, void 0, true, false, false, branch.loc);
3289
- }
3290
- else {
3291
3294
  const ret = firstChild.codegenNode;
3292
3295
  const vnodeCall = getMemoedVNodeCall(ret);
3293
3296
  if (vnodeCall.type === 13) convertToBlock(vnodeCall, context);
@@ -3308,9 +3311,10 @@ function isSameKey(a, b) {
3308
3311
  return true;
3309
3312
  }
3310
3313
  function getParentCondition(node) {
3311
- while (true) if (node.type === 19) if (node.alternate.type === 19) node = node.alternate;
3312
- else return node;
3313
- 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;
3314
3318
  }
3315
3319
  //#endregion
3316
3320
  //#region packages/compiler-core/src/transforms/vFor.ts
@@ -3348,15 +3352,24 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3348
3352
  else {
3349
3353
  childBlock = children[0].codegenNode;
3350
3354
  if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
3351
- if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
3352
- removeHelper(OPEN_BLOCK);
3353
- removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3354
- } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3355
- 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;
3356
3363
  if (childBlock.isBlock) {
3357
3364
  helper(OPEN_BLOCK);
3358
3365
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3359
- } 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
+ }
3360
3373
  }
3361
3374
  if (memo) {
3362
3375
  const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
@@ -3549,8 +3562,10 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
3549
3562
  return createObjectProperty(`default`, fn);
3550
3563
  };
3551
3564
  if (!hasTemplateSlots) slotsProperties.push(buildDefaultSlotProperty(void 0, children));
3552
- else if (implicitDefaultChildren.length && !implicitDefaultChildren.every(isWhitespaceText)) if (hasNamedDefaultSlot) context.onError(createCompilerError(39, implicitDefaultChildren[0].loc));
3553
- 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
+ }
3554
3569
  }
3555
3570
  const slotFlag = hasDynamicSlots ? 2 : hasForwardedSlots(node.children) ? 3 : 1;
3556
3571
  let slots = createObjectExpression(slotsProperties.concat(createObjectProperty(`_`, createSimpleExpression(slotFlag + (!!(process.env.NODE_ENV !== "production") ? ` /* ${slotFlagsText[slotFlag]} */` : ``), false))), loc);
@@ -3576,10 +3591,7 @@ function hasForwardedSlots(children) {
3576
3591
  if (hasForwardedSlots(child.branches)) return true;
3577
3592
  break;
3578
3593
  case 10:
3579
- case 11:
3580
- if (hasForwardedSlots(child.children)) return true;
3581
- break;
3582
- default: break;
3594
+ case 11: if (hasForwardedSlots(child.children)) return true;
3583
3595
  }
3584
3596
  }
3585
3597
  return false;
@@ -3601,12 +3613,16 @@ const transformElement = (node, context) => {
3601
3613
  let vnodeDynamicProps;
3602
3614
  let dynamicPropNames;
3603
3615
  let vnodeDirectives;
3616
+ let needsPatch = false;
3617
+ let isBlockRequired = false;
3604
3618
  let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
3605
3619
  if (props.length > 0) {
3606
3620
  const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
3607
3621
  vnodeProps = propsBuildResult.props;
3608
3622
  patchFlag = propsBuildResult.patchFlag;
3609
3623
  dynamicPropNames = propsBuildResult.dynamicPropNames;
3624
+ needsPatch = propsBuildResult.needsPatch;
3625
+ isBlockRequired = propsBuildResult.isBlockRequired;
3610
3626
  const directives = propsBuildResult.directives;
3611
3627
  vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
3612
3628
  if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
@@ -3635,7 +3651,10 @@ const transformElement = (node, context) => {
3635
3651
  } else vnodeChildren = node.children;
3636
3652
  }
3637
3653
  if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
3638
- 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;
3639
3658
  };
3640
3659
  };
3641
3660
  function resolveComponentType(node, context, ssr = false) {
@@ -3669,6 +3688,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3669
3688
  const runtimeDirectives = [];
3670
3689
  const hasChildren = children.length > 0;
3671
3690
  let shouldUseBlock = false;
3691
+ let isBlockRequired = false;
3672
3692
  let patchFlag = 0;
3673
3693
  let hasRef = false;
3674
3694
  let hasClassBinding = false;
@@ -3693,12 +3713,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3693
3713
  const isEventHandler = isOn(name);
3694
3714
  if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
3695
3715
  if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
3716
+ if (name === "ref") hasRef = true;
3696
3717
  if (isEventHandler && value.type === 14) value = value.arguments[0];
3697
3718
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
3698
- if (name === "ref") hasRef = true;
3699
- else if (name === "class") hasClassBinding = true;
3719
+ if (name === "class") hasClassBinding = true;
3700
3720
  else if (name === "style") hasStyleBinding = true;
3701
- else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3721
+ else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3702
3722
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3703
3723
  } else hasDynamicKeys = true;
3704
3724
  };
@@ -3724,35 +3744,40 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3724
3744
  if (name === "once" || name === "memo") continue;
3725
3745
  if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
3726
3746
  if (isVOn && ssr) continue;
3727
- 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
+ }
3728
3752
  if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
3729
3753
  if (!arg && (isVBind || isVOn)) {
3730
3754
  hasDynamicKeys = true;
3731
- if (exp) if (isVBind) {
3732
- pushMergeArg();
3733
- if (!!(process.env.NODE_ENV !== "production")) {
3734
- if (mergeArgs.some((arg) => {
3735
- if (arg.type === 15) return arg.properties.some(({ key }) => {
3736
- if (key.type !== 4 || !key.isStatic) return true;
3737
- return key.content !== "class" && key.content !== "style" && !isOn(key.content);
3738
- });
3739
- else return true;
3740
- })) checkCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context, loc);
3741
- }
3742
- if (isCompatEnabled("COMPILER_V_BIND_OBJECT_ORDER", context)) {
3743
- mergeArgs.unshift(exp);
3744
- continue;
3745
- }
3746
- pushRefVForMarker();
3747
- pushMergeArg();
3748
- mergeArgs.push(exp);
3749
- } else pushMergeArg({
3750
- type: 14,
3751
- loc,
3752
- callee: context.helper(TO_HANDLERS),
3753
- arguments: isComponent ? [exp] : [exp, `true`]
3754
- });
3755
- 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));
3756
3781
  continue;
3757
3782
  }
3758
3783
  if (isVBind && modifiers.some((mod) => mod.content === "prop")) patchFlag |= 32;
@@ -3768,7 +3793,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3768
3793
  }
3769
3794
  } else if (!isBuiltInDirective(name)) {
3770
3795
  runtimeDirectives.push(prop);
3771
- if (hasChildren) shouldUseBlock = true;
3796
+ if (hasChildren) {
3797
+ shouldUseBlock = true;
3798
+ isBlockRequired = true;
3799
+ }
3772
3800
  }
3773
3801
  }
3774
3802
  }
@@ -3785,7 +3813,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3785
3813
  if (dynamicPropNames.length) patchFlag |= 8;
3786
3814
  if (hasHydrationEventBinding) patchFlag |= 32;
3787
3815
  }
3788
- 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;
3789
3818
  if (!context.inSSR && propsExpression) switch (propsExpression.type) {
3790
3819
  case 15:
3791
3820
  let classKeyIndex = -1;
@@ -3806,16 +3835,16 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3806
3835
  } else propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [propsExpression]);
3807
3836
  break;
3808
3837
  case 14: break;
3809
- default:
3810
- propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3811
- break;
3838
+ default: propsExpression = createCallExpression(context.helper(NORMALIZE_PROPS), [createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [propsExpression])]);
3812
3839
  }
3813
3840
  return {
3814
3841
  props: propsExpression,
3815
3842
  directives: runtimeDirectives,
3816
3843
  patchFlag,
3817
3844
  dynamicPropNames,
3818
- shouldUseBlock
3845
+ shouldUseBlock,
3846
+ needsPatch,
3847
+ isBlockRequired
3819
3848
  };
3820
3849
  }
3821
3850
  function dedupeProperties(properties) {
@@ -3912,10 +3941,12 @@ function processSlotOutlet(node, context) {
3912
3941
  for (let i = 0; i < node.props.length; i++) {
3913
3942
  const p = node.props[i];
3914
3943
  if (p.type === 6) {
3915
- if (p.value) if (p.name === "name") slotName = JSON.stringify(p.value.content);
3916
- else {
3917
- p.name = camelize(p.name);
3918
- 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
+ }
3919
3950
  }
3920
3951
  } else if (p.name === "bind" && isStaticArgOf(p.arg, "name")) {
3921
3952
  if (p.exp) slotName = p.exp;
@@ -3941,17 +3972,18 @@ const transformOn = (dir, node, context, augmentor) => {
3941
3972
  const { loc, modifiers, arg } = dir;
3942
3973
  if (!dir.exp && !modifiers.length) context.onError(createCompilerError(35, loc));
3943
3974
  let eventName;
3944
- if (arg.type === 4) if (arg.isStatic) {
3945
- let rawName = arg.content;
3946
- if (!!(process.env.NODE_ENV !== "production") && rawName.startsWith("vnode")) context.onError(createCompilerError(52, arg.loc));
3947
- if (rawName.startsWith("vue:")) rawName = `vnode-${rawName.slice(4)}`;
3948
- eventName = createSimpleExpression(node.tagType !== 0 || rawName.startsWith("vnode") || !/[A-Z]/.test(rawName) ? toHandlerKey(camelize(rawName)) : `on:${rawName}`, true, arg.loc);
3949
- } else eventName = createCompoundExpression([
3950
- `${context.helperString(TO_HANDLER_KEY)}(`,
3951
- arg,
3952
- `)`
3953
- ]);
3954
- 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 {
3955
3987
  eventName = arg;
3956
3988
  eventName.children.unshift(`${context.helperString(TO_HANDLER_KEY)}(`);
3957
3989
  eventName.children.push(`)`);
@@ -3987,11 +4019,14 @@ const transformBind = (dir, _node, context) => {
3987
4019
  arg.children.unshift(`(`);
3988
4020
  arg.children.push(`) || ""`);
3989
4021
  } else if (!arg.isStatic) arg.content = arg.content ? `${arg.content} || ""` : `""`;
3990
- if (modifiers.some((mod) => mod.content === "camel")) if (arg.type === 4) if (arg.isStatic) arg.content = camelize(arg.content);
3991
- else arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
3992
- else {
3993
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
3994
- 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
+ }
3995
4030
  }
3996
4031
  if (!context.inSSR) {
3997
4032
  if (modifiers.some((mod) => mod.content === "prop")) injectPrefix(arg, ".");
@@ -4000,9 +4035,10 @@ const transformBind = (dir, _node, context) => {
4000
4035
  return { props: [createObjectProperty(arg, exp)] };
4001
4036
  };
4002
4037
  const injectPrefix = (arg, prefix) => {
4003
- if (arg.type === 4) if (arg.isStatic) arg.content = prefix + arg.content;
4004
- else arg.content = `\`${prefix}\${${arg.content}}\``;
4005
- else {
4038
+ if (arg.type === 4) {
4039
+ if (arg.isStatic) arg.content = prefix + arg.content;
4040
+ else arg.content = `\`${prefix}\${${arg.content}}\``;
4041
+ } else {
4006
4042
  arg.children.unshift(`'${prefix}' + (`);
4007
4043
  arg.children.push(`)`);
4008
4044
  }
@@ -4149,11 +4185,12 @@ function parseFilter(node, context) {
4149
4185
  if (c === 96 && prev !== 92) inTemplateString = false;
4150
4186
  } else if (inRegex) {
4151
4187
  if (c === 47 && prev !== 92) inRegex = false;
4152
- } else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) if (expression === void 0) {
4153
- lastFilterIndex = i + 1;
4154
- expression = exp.slice(0, i).trim();
4155
- } else pushFilter();
4156
- 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 {
4157
4194
  switch (c) {
4158
4195
  case 34:
4159
4196
  inDouble = true;
@@ -4179,9 +4216,7 @@ function parseFilter(node, context) {
4179
4216
  case 123:
4180
4217
  curly++;
4181
4218
  break;
4182
- case 125:
4183
- curly--;
4184
- break;
4219
+ case 125: curly--;
4185
4220
  }
4186
4221
  if (c === 47) {
4187
4222
  let j = i - 1;