@vue/compiler-dom 3.6.0-beta.8 → 3.6.0-rc.1

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-beta.8
2
+ * @vue/compiler-dom v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -278,7 +278,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
278
278
  source: ""
279
279
  }));
280
280
  const child = node.children[0];
281
- if (child.type === 1) {
281
+ if (child.type === 1 && !(0, _vue_compiler_core.findDir)(child, "if")) {
282
282
  for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
283
283
  type: 6,
284
284
  name: "persisted",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-beta.8
2
+ * @vue/compiler-dom v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -265,7 +265,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
265
265
  source: ""
266
266
  }));
267
267
  const child = node.children[0];
268
- if (child.type === 1) {
268
+ if (child.type === 1 && !(0, _vue_compiler_core.findDir)(child, "if")) {
269
269
  for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
270
270
  type: 6,
271
271
  name: "persisted",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-dom v3.6.0-beta.8
2
+ * @vue/compiler-dom v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -46,8 +46,6 @@ const camelizeReplacer = (_, c) => c ? c.toUpperCase() : "";
46
46
  * @private
47
47
  */
48
48
  const camelize = cacheStringFunction((str) => str.replace(camelizeRE, camelizeReplacer));
49
- const hyphenateRE = /\B([A-Z])/g;
50
- cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
51
49
  /**
52
50
  * @private
53
51
  */
@@ -1810,6 +1808,7 @@ function getUnnormalizedProps(props, callPath = []) {
1810
1808
  return [props, callPath];
1811
1809
  }
1812
1810
  function injectProp(node, prop, context) {
1811
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
1813
1812
  let propsWithInjection;
1814
1813
  /**
1815
1814
  * 1. mergeProps(...)
@@ -1848,6 +1847,20 @@ function injectProp(node, prop, context) {
1848
1847
  else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1849
1848
  else node.arguments[2] = propsWithInjection;
1850
1849
  }
1850
+ function injectSlotKey(node, prop) {
1851
+ var _node$arguments, _node$arguments2, _node$arguments3;
1852
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
1853
+ const props = node.arguments[2];
1854
+ if (props && !isString(props)) {
1855
+ const [unnormalizedProps] = getUnnormalizedProps(props);
1856
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
1857
+ }
1858
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
1859
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
1860
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
1861
+ node.arguments[5] = prop.value;
1862
+ return true;
1863
+ }
1851
1864
  function hasProp(prop, props) {
1852
1865
  let result = false;
1853
1866
  if (prop.key.type === 4) {
@@ -2157,7 +2170,7 @@ const tokenizer = new Tokenizer(stack, {
2157
2170
  }
2158
2171
  },
2159
2172
  oncdata(start, end) {
2160
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
2173
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
2161
2174
  else emitError(1, start - 9);
2162
2175
  },
2163
2176
  onprocessinginstruction(start) {
@@ -2649,7 +2662,7 @@ function getSelfName(filename) {
2649
2662
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
2650
2663
  return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
2651
2664
  }
2652
- 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 }) {
2665
+ 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 }) {
2653
2666
  const context = {
2654
2667
  filename,
2655
2668
  selfName: getSelfName(filename),
@@ -2671,6 +2684,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2671
2684
  bindingMetadata,
2672
2685
  inline,
2673
2686
  isTS,
2687
+ eventDelegation,
2674
2688
  onError,
2675
2689
  onWarn,
2676
2690
  compatConfig,
@@ -2682,8 +2696,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2682
2696
  imports: [],
2683
2697
  cached: [],
2684
2698
  constantCache: /* @__PURE__ */ new WeakMap(),
2699
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
2685
2700
  temps: 0,
2686
2701
  identifiers: Object.create(null),
2702
+ identifierScopes: Object.create(null),
2687
2703
  scopes: {
2688
2704
  vFor: 0,
2689
2705
  vSlot: 0,
@@ -2734,8 +2750,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2734
2750
  context.parent.children.splice(removalIndex, 1);
2735
2751
  },
2736
2752
  onNodeRemoved: NOOP,
2737
- addIdentifiers(exp) {},
2753
+ addIdentifiers(exp, type = "local") {},
2738
2754
  removeIdentifiers(exp) {},
2755
+ isSlotScopeIdentifier(name) {
2756
+ const scopes = context.identifierScopes[name];
2757
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
2758
+ },
2739
2759
  hoist(exp) {
2740
2760
  if (isString(exp)) exp = createSimpleExpression(exp);
2741
2761
  context.hoists.push(exp);
@@ -3099,6 +3119,7 @@ function genNode(node, context) {
3099
3119
  case 24: break;
3100
3120
  case 25: break;
3101
3121
  case 26: break;
3122
+ /* v8 ignore start */
3102
3123
  case 10: break;
3103
3124
  default:
3104
3125
  assert(false, `unhandled codegen node type: ${node.type}`);
@@ -3317,7 +3338,7 @@ const transformExpression = (node, context) => {
3317
3338
  if (dir.type === 7 && dir.name !== "for") {
3318
3339
  const exp = dir.exp;
3319
3340
  const arg = dir.arg;
3320
- 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");
3341
+ 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");
3321
3342
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3322
3343
  }
3323
3344
  }
@@ -3463,10 +3484,9 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3463
3484
  const isTemplate = isTemplateNode(node);
3464
3485
  const memo = findDir(node, "memo");
3465
3486
  const keyProp = findProp(node, `key`, false, true);
3466
- const isDirKey = keyProp && keyProp.type === 7;
3487
+ keyProp && keyProp.type;
3467
3488
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
3468
- if (memo && keyExp && isDirKey) {}
3469
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
3489
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
3470
3490
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
3471
3491
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
3472
3492
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
@@ -3510,7 +3530,7 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3510
3530
  `)`
3511
3531
  ]),
3512
3532
  createCompoundExpression([
3513
- `if (_cached`,
3533
+ `if (_cached && _cached.el`,
3514
3534
  ...keyExp ? [` && _cached.key === `, keyExp] : [],
3515
3535
  ` && ${context.helperString(IS_MEMO_SAME)}(_cached, _memo)) return _cached`
3516
3536
  ]),
@@ -4262,7 +4282,7 @@ function rewriteFilter(node, context) {
4262
4282
  const child = node.children[i];
4263
4283
  if (typeof child !== "object") continue;
4264
4284
  if (child.type === 4) parseFilter(child, context);
4265
- else if (child.type === 8) rewriteFilter(node, context);
4285
+ else if (child.type === 8) rewriteFilter(child, context);
4266
4286
  else if (child.type === 5) rewriteFilter(child.content, context);
4267
4287
  }
4268
4288
  }
@@ -4737,7 +4757,7 @@ function postTransformTransition(node, onError, hasMultipleChildren = defaultHas
4737
4757
  source: ""
4738
4758
  }));
4739
4759
  const child = node.children[0];
4740
- if (child.type === 1) {
4760
+ if (child.type === 1 && !findDir(child, "if")) {
4741
4761
  for (const p of child.props) if (p.type === 7 && p.name === "show") node.props.push({
4742
4762
  type: 6,
4743
4763
  name: "persisted",