@vue/compiler-dom 3.6.0-rc.2 → 3.6.0-rc.4

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-dom v3.6.0-rc.2
2
+ * @vue/compiler-dom v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -461,10 +461,11 @@ function stringifyElement(node, context) {
461
461
  res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
462
462
  continue;
463
463
  }
464
- if ((0, _vue_shared.isBooleanAttr)(p.arg.content) && exp.content === "false") continue;
464
+ if (((0, _vue_shared.isBooleanAttr)(p.arg.content) || p.arg.content === "hidden") && exp.content === "false") continue;
465
465
  let evaluated = evaluateConstant(exp);
466
466
  if (evaluated != null) {
467
467
  const arg = p.arg && p.arg.content;
468
+ if (arg === "hidden" && typeof evaluated === "number" && !(0, _vue_shared.includeBooleanAttr)(evaluated)) continue;
468
469
  if (arg === "class") evaluated = (0, _vue_shared.normalizeClass)(evaluated);
469
470
  else if (arg === "style") evaluated = (0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(evaluated));
470
471
  res += ` ${p.arg.content}="${(0, _vue_shared.escapeHtml)(evaluated)}"`;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-rc.2
2
+ * @vue/compiler-dom v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -448,10 +448,11 @@ function stringifyElement(node, context) {
448
448
  res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
449
449
  continue;
450
450
  }
451
- if ((0, _vue_shared.isBooleanAttr)(p.arg.content) && exp.content === "false") continue;
451
+ if (((0, _vue_shared.isBooleanAttr)(p.arg.content) || p.arg.content === "hidden") && exp.content === "false") continue;
452
452
  let evaluated = evaluateConstant(exp);
453
453
  if (evaluated != null) {
454
454
  const arg = p.arg && p.arg.content;
455
+ if (arg === "hidden" && typeof evaluated === "number" && !(0, _vue_shared.includeBooleanAttr)(evaluated)) continue;
455
456
  if (arg === "class") evaluated = (0, _vue_shared.normalizeClass)(evaluated);
456
457
  else if (arg === "style") evaluated = (0, _vue_shared.stringifyStyle)((0, _vue_shared.normalizeStyle)(evaluated));
457
458
  res += ` ${p.arg.content}="${(0, _vue_shared.escapeHtml)(evaluated)}"`;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-rc.2
2
+ * @vue/compiler-dom v3.6.0-rc.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -3510,15 +3510,22 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3510
3510
  else {
3511
3511
  childBlock = children[0].codegenNode;
3512
3512
  if (isTemplate && keyProperty) injectProp(childBlock, keyProperty, context);
3513
- if (childBlock.isBlock !== !isStableFragment) if (childBlock.isBlock) {
3513
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
3514
+ if (childBlock.isBlock !== shouldUseBlock) if (childBlock.isBlock) {
3514
3515
  removeHelper(OPEN_BLOCK);
3515
3516
  removeHelper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3516
3517
  } else removeHelper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3517
- childBlock.isBlock = !isStableFragment;
3518
+ childBlock.isBlock = shouldUseBlock;
3518
3519
  if (childBlock.isBlock) {
3519
3520
  helper(OPEN_BLOCK);
3520
3521
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
3521
- } else helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3522
+ } else {
3523
+ helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
3524
+ if (childBlock.needsPatch) {
3525
+ var _childBlock$patchFlag;
3526
+ childBlock.patchFlag = ((_childBlock$patchFlag = childBlock.patchFlag) !== null && _childBlock$patchFlag !== void 0 ? _childBlock$patchFlag : 0) | 512;
3527
+ }
3528
+ }
3522
3529
  }
3523
3530
  if (memo) {
3524
3531
  const loop = createFunctionExpression(createForLoopParams(forNode.parseResult, [createSimpleExpression(`_cached`)]));
@@ -3761,12 +3768,16 @@ const transformElement = (node, context) => {
3761
3768
  let vnodeDynamicProps;
3762
3769
  let dynamicPropNames;
3763
3770
  let vnodeDirectives;
3771
+ let needsPatch = false;
3772
+ let isBlockRequired = false;
3764
3773
  let shouldUseBlock = isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && (tag === "svg" || tag === "foreignObject" || tag === "math");
3765
3774
  if (props.length > 0) {
3766
3775
  const propsBuildResult = buildProps(node, context, void 0, isComponent, isDynamicComponent);
3767
3776
  vnodeProps = propsBuildResult.props;
3768
3777
  patchFlag = propsBuildResult.patchFlag;
3769
3778
  dynamicPropNames = propsBuildResult.dynamicPropNames;
3779
+ needsPatch = propsBuildResult.needsPatch;
3780
+ isBlockRequired = propsBuildResult.isBlockRequired;
3770
3781
  const directives = propsBuildResult.directives;
3771
3782
  vnodeDirectives = directives && directives.length ? createArrayExpression(directives.map((dir) => buildDirectiveArgs(dir, context))) : void 0;
3772
3783
  if (propsBuildResult.shouldUseBlock) shouldUseBlock = true;
@@ -3795,7 +3806,10 @@ const transformElement = (node, context) => {
3795
3806
  } else vnodeChildren = node.children;
3796
3807
  }
3797
3808
  if (dynamicPropNames && dynamicPropNames.length) vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
3798
- node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3809
+ const vnodeCall = node.codegenNode = createVNodeCall(context, vnodeTag, vnodeProps, vnodeChildren, patchFlag === 0 ? void 0 : patchFlag, vnodeDynamicProps, vnodeDirectives, !!shouldUseBlock, false, isComponent, node.loc);
3810
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
3811
+ if (needsPatch) vnodeCall.needsPatch = true;
3812
+ if (isBlockRequired) vnodeCall.isBlockRequired = true;
3799
3813
  };
3800
3814
  };
3801
3815
  function resolveComponentType(node, context, ssr = false) {
@@ -3829,6 +3843,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3829
3843
  const runtimeDirectives = [];
3830
3844
  const hasChildren = children.length > 0;
3831
3845
  let shouldUseBlock = false;
3846
+ let isBlockRequired = false;
3832
3847
  let patchFlag = 0;
3833
3848
  let hasRef = false;
3834
3849
  let hasClassBinding = false;
@@ -3853,12 +3868,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3853
3868
  const isEventHandler = isOn(name);
3854
3869
  if (isEventHandler && (!isComponent || isDynamicComponent) && name.toLowerCase() !== "onclick" && name !== "onUpdate:modelValue" && !isReservedProp(name)) hasHydrationEventBinding = true;
3855
3870
  if (isEventHandler && isReservedProp(name)) hasVnodeHook = true;
3871
+ if (name === "ref") hasRef = true;
3856
3872
  if (isEventHandler && value.type === 14) value = value.arguments[0];
3857
3873
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) return;
3858
- if (name === "ref") hasRef = true;
3859
- else if (name === "class") hasClassBinding = true;
3874
+ if (name === "class") hasClassBinding = true;
3860
3875
  else if (name === "style") hasStyleBinding = true;
3861
- else if (name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3876
+ else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3862
3877
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) dynamicPropNames.push(name);
3863
3878
  } else hasDynamicKeys = true;
3864
3879
  };
@@ -3884,7 +3899,11 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3884
3899
  if (name === "once" || name === "memo") continue;
3885
3900
  if (name === "is" || isVBind && isStaticArgOf(arg, "is") && (isComponentTag(tag) || isCompatEnabled("COMPILER_IS_ON_ELEMENT", context))) continue;
3886
3901
  if (isVOn && ssr) continue;
3887
- if (isVBind && isStaticArgOf(arg, "key") || isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")) shouldUseBlock = true;
3902
+ if (isVBind && isStaticArgOf(arg, "key")) shouldUseBlock = true;
3903
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
3904
+ shouldUseBlock = true;
3905
+ isBlockRequired = true;
3906
+ }
3888
3907
  if (isVBind && isStaticArgOf(arg, "ref")) pushRefVForMarker();
3889
3908
  if (!arg && (isVBind || isVOn)) {
3890
3909
  hasDynamicKeys = true;
@@ -3926,7 +3945,10 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3926
3945
  }
3927
3946
  } else if (!isBuiltInDirective(name)) {
3928
3947
  runtimeDirectives.push(prop);
3929
- if (hasChildren) shouldUseBlock = true;
3948
+ if (hasChildren) {
3949
+ shouldUseBlock = true;
3950
+ isBlockRequired = true;
3951
+ }
3930
3952
  }
3931
3953
  }
3932
3954
  }
@@ -3943,7 +3965,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3943
3965
  if (dynamicPropNames.length) patchFlag |= 8;
3944
3966
  if (hasHydrationEventBinding) patchFlag |= 32;
3945
3967
  }
3946
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) patchFlag |= 512;
3968
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
3969
+ if (!shouldUseBlock && needsPatch) patchFlag |= 512;
3947
3970
  if (!context.inSSR && propsExpression) switch (propsExpression.type) {
3948
3971
  case 15:
3949
3972
  let classKeyIndex = -1;
@@ -3973,7 +3996,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
3973
3996
  directives: runtimeDirectives,
3974
3997
  patchFlag,
3975
3998
  dynamicPropNames,
3976
- shouldUseBlock
3999
+ shouldUseBlock,
4000
+ needsPatch,
4001
+ isBlockRequired
3977
4002
  };
3978
4003
  }
3979
4004
  function dedupeProperties(properties) {