@vue/compiler-dom 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-dom v3.5.39
2
+ * @vue/compiler-dom v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -623,12 +623,15 @@ function stringifyElement(node, context) {
623
623
  res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
624
624
  continue;
625
625
  }
626
- if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
626
+ if ((shared.isBooleanAttr(p.arg.content) || p.arg.content === "hidden") && exp.content === "false") {
627
627
  continue;
628
628
  }
629
629
  let evaluated = evaluateConstant(exp);
630
630
  if (evaluated != null) {
631
631
  const arg = p.arg && p.arg.content;
632
+ if (arg === "hidden" && typeof evaluated === "number" && !shared.includeBooleanAttr(evaluated)) {
633
+ continue;
634
+ }
632
635
  if (arg === "class") {
633
636
  evaluated = shared.normalizeClass(evaluated);
634
637
  } else if (arg === "style") {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.39
2
+ * @vue/compiler-dom v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -559,12 +559,15 @@ function stringifyElement(node, context) {
559
559
  res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
560
560
  continue;
561
561
  }
562
- if (shared.isBooleanAttr(p.arg.content) && exp.content === "false") {
562
+ if ((shared.isBooleanAttr(p.arg.content) || p.arg.content === "hidden") && exp.content === "false") {
563
563
  continue;
564
564
  }
565
565
  let evaluated = evaluateConstant(exp);
566
566
  if (evaluated != null) {
567
567
  const arg = p.arg && p.arg.content;
568
+ if (arg === "hidden" && typeof evaluated === "number" && !shared.includeBooleanAttr(evaluated)) {
569
+ continue;
570
+ }
568
571
  if (arg === "class") {
569
572
  evaluated = shared.normalizeClass(evaluated);
570
573
  } else if (arg === "style") {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.5.39
2
+ * @vue/compiler-dom v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1952,6 +1952,9 @@ function getUnnormalizedProps(props, callPath = []) {
1952
1952
  return [props, callPath];
1953
1953
  }
1954
1954
  function injectProp(node, prop, context) {
1955
+ if (node.type !== 13 && injectSlotKey(node, prop)) {
1956
+ return;
1957
+ }
1955
1958
  let propsWithInjection;
1956
1959
  let props = node.type === 13 ? node.props : node.arguments[2];
1957
1960
  let callPath = [];
@@ -2009,6 +2012,24 @@ function injectProp(node, prop, context) {
2009
2012
  }
2010
2013
  }
2011
2014
  }
2015
+ function injectSlotKey(node, prop) {
2016
+ var _a, _b, _c;
2017
+ if (prop.key.type !== 4 || prop.key.content !== "key") {
2018
+ return false;
2019
+ }
2020
+ const props = node.arguments[2];
2021
+ if (props && !isString(props)) {
2022
+ const [unnormalizedProps] = getUnnormalizedProps(props);
2023
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) {
2024
+ return true;
2025
+ }
2026
+ }
2027
+ (_a = node.arguments)[2] || (_a[2] = "{}");
2028
+ (_b = node.arguments)[3] || (_b[3] = "undefined");
2029
+ (_c = node.arguments)[4] || (_c[4] = "undefined");
2030
+ node.arguments[5] = prop.value;
2031
+ return true;
2032
+ }
2012
2033
  function hasProp(prop, props) {
2013
2034
  let result = false;
2014
2035
  if (prop.key.type === 4) {
@@ -4324,6 +4345,7 @@ const transformFor = createStructuralDirectiveTransform(
4324
4345
  node.loc
4325
4346
  );
4326
4347
  return () => {
4348
+ var _a;
4327
4349
  let childBlock;
4328
4350
  const { children } = forNode;
4329
4351
  if (isTemplate) {
@@ -4367,7 +4389,8 @@ const transformFor = createStructuralDirectiveTransform(
4367
4389
  if (isTemplate && keyProperty) {
4368
4390
  injectProp(childBlock, keyProperty, context);
4369
4391
  }
4370
- if (childBlock.isBlock !== !isStableFragment) {
4392
+ const shouldUseBlock = !isStableFragment || childBlock.isBlockRequired === true;
4393
+ if (childBlock.isBlock !== shouldUseBlock) {
4371
4394
  if (childBlock.isBlock) {
4372
4395
  removeHelper(OPEN_BLOCK);
4373
4396
  removeHelper(
@@ -4379,12 +4402,15 @@ const transformFor = createStructuralDirectiveTransform(
4379
4402
  );
4380
4403
  }
4381
4404
  }
4382
- childBlock.isBlock = !isStableFragment;
4405
+ childBlock.isBlock = shouldUseBlock;
4383
4406
  if (childBlock.isBlock) {
4384
4407
  helper(OPEN_BLOCK);
4385
4408
  helper(getVNodeBlockHelper(context.inSSR, childBlock.isComponent));
4386
4409
  } else {
4387
4410
  helper(getVNodeHelper(context.inSSR, childBlock.isComponent));
4411
+ if (childBlock.needsPatch) {
4412
+ childBlock.patchFlag = ((_a = childBlock.patchFlag) != null ? _a : 0) | 512;
4413
+ }
4388
4414
  }
4389
4415
  }
4390
4416
  if (memo) {
@@ -4782,6 +4808,8 @@ const transformElement = (node, context) => {
4782
4808
  let vnodeDynamicProps;
4783
4809
  let dynamicPropNames;
4784
4810
  let vnodeDirectives;
4811
+ let needsPatch = false;
4812
+ let isBlockRequired = false;
4785
4813
  let shouldUseBlock = (
4786
4814
  // dynamic component may resolve to plain elements
4787
4815
  isDynamicComponent || vnodeTag === TELEPORT || vnodeTag === SUSPENSE || !isComponent && // <svg> and <foreignObject> must be forced into blocks so that block
@@ -4801,6 +4829,8 @@ const transformElement = (node, context) => {
4801
4829
  vnodeProps = propsBuildResult.props;
4802
4830
  patchFlag = propsBuildResult.patchFlag;
4803
4831
  dynamicPropNames = propsBuildResult.dynamicPropNames;
4832
+ needsPatch = propsBuildResult.needsPatch;
4833
+ isBlockRequired = propsBuildResult.isBlockRequired;
4804
4834
  const directives = propsBuildResult.directives;
4805
4835
  vnodeDirectives = directives && directives.length ? createArrayExpression(
4806
4836
  directives.map((dir) => buildDirectiveArgs(dir, context))
@@ -4851,7 +4881,7 @@ const transformElement = (node, context) => {
4851
4881
  if (dynamicPropNames && dynamicPropNames.length) {
4852
4882
  vnodeDynamicProps = stringifyDynamicPropNames(dynamicPropNames);
4853
4883
  }
4854
- node.codegenNode = createVNodeCall(
4884
+ const vnodeCall = node.codegenNode = createVNodeCall(
4855
4885
  context,
4856
4886
  vnodeTag,
4857
4887
  vnodeProps,
@@ -4864,6 +4894,13 @@ const transformElement = (node, context) => {
4864
4894
  isComponent,
4865
4895
  node.loc
4866
4896
  );
4897
+ needsPatch = needsPatch && (patchFlag === 0 || patchFlag === 32);
4898
+ if (needsPatch) {
4899
+ vnodeCall.needsPatch = true;
4900
+ }
4901
+ if (isBlockRequired) {
4902
+ vnodeCall.isBlockRequired = true;
4903
+ }
4867
4904
  };
4868
4905
  };
4869
4906
  function resolveComponentType(node, context, ssr = false) {
@@ -4915,6 +4952,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4915
4952
  const runtimeDirectives = [];
4916
4953
  const hasChildren = children.length > 0;
4917
4954
  let shouldUseBlock = false;
4955
+ let isBlockRequired = false;
4918
4956
  let patchFlag = 0;
4919
4957
  let hasRef = false;
4920
4958
  let hasClassBinding = false;
@@ -4956,19 +4994,20 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
4956
4994
  if (isEventHandler && isReservedProp(name)) {
4957
4995
  hasVnodeHook = true;
4958
4996
  }
4997
+ if (name === "ref") {
4998
+ hasRef = true;
4999
+ }
4959
5000
  if (isEventHandler && value.type === 14) {
4960
5001
  value = value.arguments[0];
4961
5002
  }
4962
5003
  if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
4963
5004
  return;
4964
5005
  }
4965
- if (name === "ref") {
4966
- hasRef = true;
4967
- } else if (name === "class") {
5006
+ if (name === "class") {
4968
5007
  hasClassBinding = true;
4969
5008
  } else if (name === "style") {
4970
5009
  hasStyleBinding = true;
4971
- } else if (name !== "key" && !dynamicPropNames.includes(name)) {
5010
+ } else if (name !== "ref" && name !== "key" && !dynamicPropNames.includes(name)) {
4972
5011
  dynamicPropNames.push(name);
4973
5012
  }
4974
5013
  if (isComponent && (name === "class" || name === "style") && !dynamicPropNames.includes(name)) {
@@ -5027,13 +5066,12 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5027
5066
  if (isVOn && ssr) {
5028
5067
  continue;
5029
5068
  }
5030
- if (
5031
- // #938: elements with dynamic keys should be forced into blocks
5032
- isVBind && isStaticArgOf(arg, "key") || // inline before-update hooks need to force block so that it is invoked
5033
- // before children
5034
- isVOn && hasChildren && isStaticArgOf(arg, "vue:before-update")
5035
- ) {
5069
+ if (isVBind && isStaticArgOf(arg, "key")) {
5070
+ shouldUseBlock = true;
5071
+ }
5072
+ if (isVOn && hasChildren && arg && isStaticExp(arg) && camelize(arg.content) === "vue:beforeUpdate") {
5036
5073
  shouldUseBlock = true;
5074
+ isBlockRequired = true;
5037
5075
  }
5038
5076
  if (isVBind && isStaticArgOf(arg, "ref")) {
5039
5077
  pushRefVForMarker();
@@ -5116,6 +5154,7 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5116
5154
  runtimeDirectives.push(prop);
5117
5155
  if (hasChildren) {
5118
5156
  shouldUseBlock = true;
5157
+ isBlockRequired = true;
5119
5158
  }
5120
5159
  }
5121
5160
  }
@@ -5154,7 +5193,8 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5154
5193
  patchFlag |= 32;
5155
5194
  }
5156
5195
  }
5157
- if (!shouldUseBlock && (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0)) {
5196
+ const needsPatch = (patchFlag === 0 || patchFlag === 32) && (hasRef || hasVnodeHook || runtimeDirectives.length > 0);
5197
+ if (!shouldUseBlock && needsPatch) {
5158
5198
  patchFlag |= 512;
5159
5199
  }
5160
5200
  if (!context.inSSR && propsExpression) {
@@ -5220,7 +5260,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
5220
5260
  directives: runtimeDirectives,
5221
5261
  patchFlag,
5222
5262
  dynamicPropNames,
5223
- shouldUseBlock
5263
+ shouldUseBlock,
5264
+ needsPatch,
5265
+ isBlockRequired
5224
5266
  };
5225
5267
  }
5226
5268
  function dedupeProperties(properties) {