@vue/compiler-core 3.6.0-beta.9 → 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-core v3.6.0-beta.9
2
+ * @vue/compiler-core v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2288,6 +2288,7 @@ function getUnnormalizedProps(props, callPath = []) {
2288
2288
  return [props, callPath];
2289
2289
  }
2290
2290
  function injectProp(node, prop, context) {
2291
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
2291
2292
  let propsWithInjection;
2292
2293
  /**
2293
2294
  * 1. mergeProps(...)
@@ -2326,6 +2327,20 @@ function injectProp(node, prop, context) {
2326
2327
  else if (parentCall) parentCall.arguments[0] = propsWithInjection;
2327
2328
  else node.arguments[2] = propsWithInjection;
2328
2329
  }
2330
+ function injectSlotKey(node, prop) {
2331
+ var _node$arguments, _node$arguments2, _node$arguments3;
2332
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
2333
+ const props = node.arguments[2];
2334
+ if (props && !(0, _vue_shared.isString)(props)) {
2335
+ const [unnormalizedProps] = getUnnormalizedProps(props);
2336
+ if (unnormalizedProps && !(0, _vue_shared.isString)(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
2337
+ }
2338
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
2339
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
2340
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
2341
+ node.arguments[5] = prop.value;
2342
+ return true;
2343
+ }
2329
2344
  function hasProp(prop, props) {
2330
2345
  let result = false;
2331
2346
  if (prop.key.type === 4) {
@@ -2636,7 +2651,7 @@ const tokenizer = new Tokenizer(stack, {
2636
2651
  }
2637
2652
  },
2638
2653
  oncdata(start, end) {
2639
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
2654
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
2640
2655
  else emitError(1, start - 9);
2641
2656
  },
2642
2657
  onprocessinginstruction(start) {
@@ -3141,7 +3156,7 @@ function getSelfName(filename) {
3141
3156
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
3142
3157
  return nameMatch ? (0, _vue_shared.capitalize)((0, _vue_shared.camelize)(nameMatch[1])) : null;
3143
3158
  }
3144
- function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = _vue_shared.NOOP, isCustomElement = _vue_shared.NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = _vue_shared.EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
3159
+ function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = _vue_shared.NOOP, isCustomElement = _vue_shared.NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = _vue_shared.EMPTY_OBJ, inline = false, isTS = false, eventDelegation = true, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
3145
3160
  const context = {
3146
3161
  filename,
3147
3162
  selfName: getSelfName(filename),
@@ -3163,6 +3178,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3163
3178
  bindingMetadata,
3164
3179
  inline,
3165
3180
  isTS,
3181
+ eventDelegation,
3166
3182
  onError,
3167
3183
  onWarn,
3168
3184
  compatConfig,
@@ -3174,8 +3190,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3174
3190
  imports: [],
3175
3191
  cached: [],
3176
3192
  constantCache: /* @__PURE__ */ new WeakMap(),
3193
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
3177
3194
  temps: 0,
3178
3195
  identifiers: Object.create(null),
3196
+ identifierScopes: Object.create(null),
3179
3197
  scopes: {
3180
3198
  vFor: 0,
3181
3199
  vSlot: 0,
@@ -3226,16 +3244,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3226
3244
  context.parent.children.splice(removalIndex, 1);
3227
3245
  },
3228
3246
  onNodeRemoved: _vue_shared.NOOP,
3229
- addIdentifiers(exp) {
3230
- if ((0, _vue_shared.isString)(exp)) addId(exp);
3231
- else if (exp.identifiers) exp.identifiers.forEach(addId);
3232
- else if (exp.type === 4) addId(exp.content);
3247
+ addIdentifiers(exp, type = "local") {
3248
+ if ((0, _vue_shared.isString)(exp)) addId(exp, type);
3249
+ else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
3250
+ else if (exp.type === 4) addId(exp.content, type);
3233
3251
  },
3234
3252
  removeIdentifiers(exp) {
3235
3253
  if ((0, _vue_shared.isString)(exp)) removeId(exp);
3236
3254
  else if (exp.identifiers) exp.identifiers.forEach(removeId);
3237
3255
  else if (exp.type === 4) removeId(exp.content);
3238
3256
  },
3257
+ isSlotScopeIdentifier(name) {
3258
+ const scopes = context.identifierScopes[name];
3259
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
3260
+ },
3239
3261
  hoist(exp) {
3240
3262
  if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
3241
3263
  context.hoists.push(exp);
@@ -3250,13 +3272,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3250
3272
  }
3251
3273
  };
3252
3274
  context.filters = /* @__PURE__ */ new Set();
3253
- function addId(id) {
3254
- const { identifiers } = context;
3275
+ function addId(id, type) {
3276
+ const { identifiers, identifierScopes } = context;
3255
3277
  if (identifiers[id] === void 0) identifiers[id] = 0;
3256
3278
  identifiers[id]++;
3279
+ (identifierScopes[id] || (identifierScopes[id] = [])).push(type);
3257
3280
  }
3258
3281
  function removeId(id) {
3259
3282
  context.identifiers[id]--;
3283
+ const scopes = context.identifierScopes[id];
3284
+ if (scopes) scopes.pop();
3260
3285
  }
3261
3286
  return context;
3262
3287
  }
@@ -3693,6 +3718,7 @@ function genNode(node, context) {
3693
3718
  case 26:
3694
3719
  genReturnStatement(node, context);
3695
3720
  break;
3721
+ /* v8 ignore start */
3696
3722
  case 10: break;
3697
3723
  default:
3698
3724
  assert(false, `unhandled codegen node type: ${node.type}`);
@@ -3945,7 +3971,7 @@ const transformExpression = (node, context) => {
3945
3971
  if (dir.type === 7 && dir.name !== "for") {
3946
3972
  const exp = dir.exp;
3947
3973
  const arg = dir.arg;
3948
- 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");
3974
+ 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");
3949
3975
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3950
3976
  }
3951
3977
  }
@@ -4203,11 +4229,11 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
4203
4229
  const keyProp = findProp(node, `key`, false, true);
4204
4230
  const isDirKey = keyProp && keyProp.type === 7;
4205
4231
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4206
- if (memo && keyExp && isDirKey) keyProp.exp = keyExp = processExpression(keyExp, context);
4207
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4208
- if (isTemplate) {
4209
- if (memo) memo.exp = processExpression(memo.exp, context);
4210
- if (keyProperty && keyProp.type !== 6) keyProperty.value = processExpression(keyProperty.value, context);
4232
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
4233
+ if (isTemplate && memo) memo.exp = processExpression(memo.exp, context);
4234
+ if ((isTemplate || memo) && keyProperty && isDirKey) {
4235
+ keyExp = keyProp.exp = keyProperty.value = processExpression(keyProperty.value, context);
4236
+ if (memo) context.vForMemoKeyedNodes.add(node);
4211
4237
  }
4212
4238
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
4213
4239
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
@@ -4338,7 +4364,7 @@ const trackSlotScopes = (node, context) => {
4338
4364
  const vSlot = findDir(node, "slot");
4339
4365
  if (vSlot) {
4340
4366
  const slotProps = vSlot.exp;
4341
- if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
4367
+ if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
4342
4368
  context.scopes.vSlot++;
4343
4369
  return () => {
4344
4370
  if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
@@ -4559,6 +4585,15 @@ function resolveComponentType(node, context, ssr = false) {
4559
4585
  if (!ssr) context.helper(builtIn);
4560
4586
  return builtIn;
4561
4587
  }
4588
+ {
4589
+ const fromScope = resolveSlotScopeReference(tag, context);
4590
+ if (fromScope) return fromScope;
4591
+ const dotIndex = tag.indexOf(".");
4592
+ if (dotIndex > 0) {
4593
+ const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
4594
+ if (ns) return ns + tag.slice(dotIndex);
4595
+ }
4596
+ }
4562
4597
  {
4563
4598
  const fromSetup = resolveSetupReference(tag, context);
4564
4599
  if (fromSetup) return fromSetup;
@@ -4577,6 +4612,14 @@ function resolveComponentType(node, context, ssr = false) {
4577
4612
  context.components.add(tag);
4578
4613
  return toValidAssetId(tag, `component`);
4579
4614
  }
4615
+ function resolveSlotScopeReference(name, context) {
4616
+ const camelName = (0, _vue_shared.camelize)(name);
4617
+ const PascalName = (0, _vue_shared.capitalize)(camelName);
4618
+ const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
4619
+ if (isInSlotScope(name)) return name;
4620
+ if (isInSlotScope(camelName)) return camelName;
4621
+ if (isInSlotScope(PascalName)) return PascalName;
4622
+ }
4580
4623
  function resolveSetupReference(name, context) {
4581
4624
  const bindings = context.bindingMetadata;
4582
4625
  if (!bindings || bindings.__isScriptSetup === false) return;
@@ -5102,7 +5145,7 @@ function rewriteFilter(node, context) {
5102
5145
  const child = node.children[i];
5103
5146
  if (typeof child !== "object") continue;
5104
5147
  if (child.type === 4) parseFilter(child, context);
5105
- else if (child.type === 8) rewriteFilter(node, context);
5148
+ else if (child.type === 8) rewriteFilter(child, context);
5106
5149
  else if (child.type === 5) rewriteFilter(child.content, context);
5107
5150
  }
5108
5151
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-beta.9
2
+ * @vue/compiler-core v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2284,6 +2284,7 @@ function getUnnormalizedProps(props, callPath = []) {
2284
2284
  return [props, callPath];
2285
2285
  }
2286
2286
  function injectProp(node, prop, context) {
2287
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
2287
2288
  let propsWithInjection;
2288
2289
  /**
2289
2290
  * 1. mergeProps(...)
@@ -2322,6 +2323,20 @@ function injectProp(node, prop, context) {
2322
2323
  else if (parentCall) parentCall.arguments[0] = propsWithInjection;
2323
2324
  else node.arguments[2] = propsWithInjection;
2324
2325
  }
2326
+ function injectSlotKey(node, prop) {
2327
+ var _node$arguments, _node$arguments2, _node$arguments3;
2328
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
2329
+ const props = node.arguments[2];
2330
+ if (props && !(0, _vue_shared.isString)(props)) {
2331
+ const [unnormalizedProps] = getUnnormalizedProps(props);
2332
+ if (unnormalizedProps && !(0, _vue_shared.isString)(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
2333
+ }
2334
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
2335
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
2336
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
2337
+ node.arguments[5] = prop.value;
2338
+ return true;
2339
+ }
2325
2340
  function hasProp(prop, props) {
2326
2341
  let result = false;
2327
2342
  if (prop.key.type === 4) {
@@ -2632,7 +2647,7 @@ const tokenizer = new Tokenizer(stack, {
2632
2647
  }
2633
2648
  },
2634
2649
  oncdata(start, end) {
2635
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
2650
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
2636
2651
  else emitError(1, start - 9);
2637
2652
  },
2638
2653
  onprocessinginstruction(start) {
@@ -3120,7 +3135,7 @@ function getSelfName(filename) {
3120
3135
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
3121
3136
  return nameMatch ? (0, _vue_shared.capitalize)((0, _vue_shared.camelize)(nameMatch[1])) : null;
3122
3137
  }
3123
- function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = _vue_shared.NOOP, isCustomElement = _vue_shared.NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = _vue_shared.EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
3138
+ function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = _vue_shared.NOOP, isCustomElement = _vue_shared.NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = _vue_shared.EMPTY_OBJ, inline = false, isTS = false, eventDelegation = true, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
3124
3139
  const context = {
3125
3140
  filename,
3126
3141
  selfName: getSelfName(filename),
@@ -3142,6 +3157,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3142
3157
  bindingMetadata,
3143
3158
  inline,
3144
3159
  isTS,
3160
+ eventDelegation,
3145
3161
  onError,
3146
3162
  onWarn,
3147
3163
  compatConfig,
@@ -3153,8 +3169,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3153
3169
  imports: [],
3154
3170
  cached: [],
3155
3171
  constantCache: /* @__PURE__ */ new WeakMap(),
3172
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
3156
3173
  temps: 0,
3157
3174
  identifiers: Object.create(null),
3175
+ identifierScopes: Object.create(null),
3158
3176
  scopes: {
3159
3177
  vFor: 0,
3160
3178
  vSlot: 0,
@@ -3199,16 +3217,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3199
3217
  context.parent.children.splice(removalIndex, 1);
3200
3218
  },
3201
3219
  onNodeRemoved: _vue_shared.NOOP,
3202
- addIdentifiers(exp) {
3203
- if ((0, _vue_shared.isString)(exp)) addId(exp);
3204
- else if (exp.identifiers) exp.identifiers.forEach(addId);
3205
- else if (exp.type === 4) addId(exp.content);
3220
+ addIdentifiers(exp, type = "local") {
3221
+ if ((0, _vue_shared.isString)(exp)) addId(exp, type);
3222
+ else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
3223
+ else if (exp.type === 4) addId(exp.content, type);
3206
3224
  },
3207
3225
  removeIdentifiers(exp) {
3208
3226
  if ((0, _vue_shared.isString)(exp)) removeId(exp);
3209
3227
  else if (exp.identifiers) exp.identifiers.forEach(removeId);
3210
3228
  else if (exp.type === 4) removeId(exp.content);
3211
3229
  },
3230
+ isSlotScopeIdentifier(name) {
3231
+ const scopes = context.identifierScopes[name];
3232
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
3233
+ },
3212
3234
  hoist(exp) {
3213
3235
  if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
3214
3236
  context.hoists.push(exp);
@@ -3223,13 +3245,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3223
3245
  }
3224
3246
  };
3225
3247
  context.filters = /* @__PURE__ */ new Set();
3226
- function addId(id) {
3227
- const { identifiers } = context;
3248
+ function addId(id, type) {
3249
+ const { identifiers, identifierScopes } = context;
3228
3250
  if (identifiers[id] === void 0) identifiers[id] = 0;
3229
3251
  identifiers[id]++;
3252
+ (identifierScopes[id] || (identifierScopes[id] = [])).push(type);
3230
3253
  }
3231
3254
  function removeId(id) {
3232
3255
  context.identifiers[id]--;
3256
+ const scopes = context.identifierScopes[id];
3257
+ if (scopes) scopes.pop();
3233
3258
  }
3234
3259
  return context;
3235
3260
  }
@@ -3661,6 +3686,7 @@ function genNode(node, context) {
3661
3686
  case 26:
3662
3687
  genReturnStatement(node, context);
3663
3688
  break;
3689
+ /* v8 ignore start */
3664
3690
  case 10: break;
3665
3691
  default:
3666
3692
  }
@@ -3910,7 +3936,7 @@ const transformExpression = (node, context) => {
3910
3936
  if (dir.type === 7 && dir.name !== "for") {
3911
3937
  const exp = dir.exp;
3912
3938
  const arg = dir.arg;
3913
- 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");
3939
+ 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");
3914
3940
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3915
3941
  }
3916
3942
  }
@@ -4161,11 +4187,11 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
4161
4187
  const keyProp = findProp(node, `key`, false, true);
4162
4188
  const isDirKey = keyProp && keyProp.type === 7;
4163
4189
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
4164
- if (memo && keyExp && isDirKey) keyProp.exp = keyExp = processExpression(keyExp, context);
4165
- const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
4166
- if (isTemplate) {
4167
- if (memo) memo.exp = processExpression(memo.exp, context);
4168
- if (keyProperty && keyProp.type !== 6) keyProperty.value = processExpression(keyProperty.value, context);
4190
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
4191
+ if (isTemplate && memo) memo.exp = processExpression(memo.exp, context);
4192
+ if ((isTemplate || memo) && keyProperty && isDirKey) {
4193
+ keyExp = keyProp.exp = keyProperty.value = processExpression(keyProperty.value, context);
4194
+ if (memo) context.vForMemoKeyedNodes.add(node);
4169
4195
  }
4170
4196
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
4171
4197
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
@@ -4296,7 +4322,7 @@ const trackSlotScopes = (node, context) => {
4296
4322
  const vSlot = findDir(node, "slot");
4297
4323
  if (vSlot) {
4298
4324
  const slotProps = vSlot.exp;
4299
- if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
4325
+ if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
4300
4326
  context.scopes.vSlot++;
4301
4327
  return () => {
4302
4328
  if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
@@ -4512,6 +4538,15 @@ function resolveComponentType(node, context, ssr = false) {
4512
4538
  if (!ssr) context.helper(builtIn);
4513
4539
  return builtIn;
4514
4540
  }
4541
+ {
4542
+ const fromScope = resolveSlotScopeReference(tag, context);
4543
+ if (fromScope) return fromScope;
4544
+ const dotIndex = tag.indexOf(".");
4545
+ if (dotIndex > 0) {
4546
+ const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
4547
+ if (ns) return ns + tag.slice(dotIndex);
4548
+ }
4549
+ }
4515
4550
  {
4516
4551
  const fromSetup = resolveSetupReference(tag, context);
4517
4552
  if (fromSetup) return fromSetup;
@@ -4530,6 +4565,14 @@ function resolveComponentType(node, context, ssr = false) {
4530
4565
  context.components.add(tag);
4531
4566
  return toValidAssetId(tag, `component`);
4532
4567
  }
4568
+ function resolveSlotScopeReference(name, context) {
4569
+ const camelName = (0, _vue_shared.camelize)(name);
4570
+ const PascalName = (0, _vue_shared.capitalize)(camelName);
4571
+ const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
4572
+ if (isInSlotScope(name)) return name;
4573
+ if (isInSlotScope(camelName)) return camelName;
4574
+ if (isInSlotScope(PascalName)) return PascalName;
4575
+ }
4533
4576
  function resolveSetupReference(name, context) {
4534
4577
  const bindings = context.bindingMetadata;
4535
4578
  if (!bindings || bindings.__isScriptSetup === false) return;
@@ -5047,7 +5090,7 @@ function rewriteFilter(node, context) {
5047
5090
  const child = node.children[i];
5048
5091
  if (typeof child !== "object") continue;
5049
5092
  if (child.type === 4) parseFilter(child, context);
5050
- else if (child.type === 8) rewriteFilter(node, context);
5093
+ else if (child.type === 8) rewriteFilter(child, context);
5051
5094
  else if (child.type === 5) rewriteFilter(child.content, context);
5052
5095
  }
5053
5096
  }
@@ -90,6 +90,7 @@ export interface ImportItem {
90
90
  exp: SimpleExpressionNode;
91
91
  path: string;
92
92
  }
93
+ type IdentifierScopeType = "local" | "slot";
93
94
  export interface TransformContext extends Required<Omit<TransformOptions, keyof CompilerCompatOptions>>, CompilerCompatOptions {
94
95
  selfName: string | null;
95
96
  root: RootNode;
@@ -103,6 +104,9 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
103
104
  identifiers: {
104
105
  [name: string]: number | undefined;
105
106
  };
107
+ identifierScopes: {
108
+ [name: string]: IdentifierScopeType[] | undefined;
109
+ };
106
110
  scopes: {
107
111
  vFor: number;
108
112
  vSlot: number;
@@ -120,11 +124,13 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
120
124
  replaceNode(node: TemplateChildNode): void;
121
125
  removeNode(node?: TemplateChildNode): void;
122
126
  onNodeRemoved(): void;
123
- addIdentifiers(exp: ExpressionNode | string): void;
127
+ addIdentifiers(exp: ExpressionNode | string, type?: IdentifierScopeType): void;
124
128
  removeIdentifiers(exp: ExpressionNode | string): void;
129
+ isSlotScopeIdentifier(name: string): boolean;
125
130
  hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
126
131
  cache(exp: JSChildNode, isVNode?: boolean, inVOnce?: boolean): CacheExpression;
127
132
  constantCache: WeakMap<TemplateChildNode, ConstantTypes>;
133
+ vForMemoKeyedNodes: WeakSet<ElementNode>;
128
134
  filters?: Set<string>;
129
135
  }
130
136
  export declare function getSelfName(filename: string): string | null;
@@ -148,6 +154,7 @@ export declare function createTransformContext(root: RootNode, {
148
154
  bindingMetadata,
149
155
  inline,
150
156
  isTS,
157
+ eventDelegation,
151
158
  onError,
152
159
  onWarn,
153
160
  compatConfig
@@ -497,7 +504,7 @@ export interface DirectiveArgumentNode extends ArrayExpression {
497
504
  }
498
505
  export interface RenderSlotCall extends CallExpression {
499
506
  callee: typeof RENDER_SLOT;
500
- arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [string, string | ExpressionNode, PropsExpression | "{}", TemplateChildNode[]];
507
+ arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression | "{}"] | [string, string | ExpressionNode, PropsExpression | "{}", FunctionExpression | string] | [string, string | ExpressionNode, PropsExpression | "{}", FunctionExpression | string, string] | [string, string | ExpressionNode, PropsExpression | "{}", FunctionExpression | string, string, JSChildNode];
501
508
  }
502
509
  export type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
503
510
  export interface SlotsObjectExpression extends ObjectExpression {
@@ -922,6 +929,12 @@ export interface TransformOptions extends SharedTransformCodegenOptions, ErrorHa
922
929
  * correctly, e.g. #6938, #7138
923
930
  */
924
931
  hmr?: boolean;
932
+ /**
933
+ * Vapor only: control whether eligible static DOM events are compiled to
934
+ * document-level delegated events.
935
+ * @default true
936
+ */
937
+ eventDelegation?: boolean;
925
938
  }
926
939
  export interface CodegenOptions extends SharedTransformCodegenOptions {
927
940
  /**
@@ -976,7 +989,7 @@ export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
976
989
  *
977
990
  * Since TS 5.3, dts generation starts to strangely include broken triple slash
978
991
  * references for source-map-js, so we are inlining all source map related types
979
- * here to to workaround that.
992
+ * here to workaround that.
980
993
  */
981
994
  export interface CodegenSourceMapGenerator {
982
995
  setSourceContent(sourceFile: string, sourceContent: string): void;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-beta.9
2
+ * @vue/compiler-core v3.6.0-rc.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1634,6 +1634,7 @@ function getUnnormalizedProps(props, callPath = []) {
1634
1634
  return [props, callPath];
1635
1635
  }
1636
1636
  function injectProp(node, prop, context) {
1637
+ if (node.type !== 13 && injectSlotKey(node, prop)) return;
1637
1638
  let propsWithInjection;
1638
1639
  /**
1639
1640
  * 1. mergeProps(...)
@@ -1672,6 +1673,20 @@ function injectProp(node, prop, context) {
1672
1673
  else if (parentCall) parentCall.arguments[0] = propsWithInjection;
1673
1674
  else node.arguments[2] = propsWithInjection;
1674
1675
  }
1676
+ function injectSlotKey(node, prop) {
1677
+ var _node$arguments, _node$arguments2, _node$arguments3;
1678
+ if (prop.key.type !== 4 || prop.key.content !== "key") return false;
1679
+ const props = node.arguments[2];
1680
+ if (props && !isString(props)) {
1681
+ const [unnormalizedProps] = getUnnormalizedProps(props);
1682
+ if (unnormalizedProps && !isString(unnormalizedProps) && unnormalizedProps.type === 15 && hasProp(prop, unnormalizedProps)) return true;
1683
+ }
1684
+ (_node$arguments = node.arguments)[2] || (_node$arguments[2] = "{}");
1685
+ (_node$arguments2 = node.arguments)[3] || (_node$arguments2[3] = "undefined");
1686
+ (_node$arguments3 = node.arguments)[4] || (_node$arguments3[4] = "undefined");
1687
+ node.arguments[5] = prop.value;
1688
+ return true;
1689
+ }
1675
1690
  function hasProp(prop, props) {
1676
1691
  let result = false;
1677
1692
  if (prop.key.type === 4) {
@@ -1983,7 +1998,7 @@ const tokenizer = new Tokenizer(stack, {
1983
1998
  }
1984
1999
  },
1985
2000
  oncdata(start, end) {
1986
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
2001
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
1987
2002
  else emitError(1, start - 9);
1988
2003
  },
1989
2004
  onprocessinginstruction(start) {
@@ -2479,7 +2494,7 @@ function getSelfName(filename) {
2479
2494
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
2480
2495
  return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
2481
2496
  }
2482
- 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 }) {
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 }) {
2483
2498
  const context = {
2484
2499
  filename,
2485
2500
  selfName: getSelfName(filename),
@@ -2501,6 +2516,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2501
2516
  bindingMetadata,
2502
2517
  inline,
2503
2518
  isTS,
2519
+ eventDelegation,
2504
2520
  onError,
2505
2521
  onWarn,
2506
2522
  compatConfig,
@@ -2512,8 +2528,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2512
2528
  imports: [],
2513
2529
  cached: [],
2514
2530
  constantCache: /* @__PURE__ */ new WeakMap(),
2531
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
2515
2532
  temps: 0,
2516
2533
  identifiers: Object.create(null),
2534
+ identifierScopes: Object.create(null),
2517
2535
  scopes: {
2518
2536
  vFor: 0,
2519
2537
  vSlot: 0,
@@ -2567,8 +2585,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2567
2585
  context.parent.children.splice(removalIndex, 1);
2568
2586
  },
2569
2587
  onNodeRemoved: NOOP,
2570
- addIdentifiers(exp) {},
2588
+ addIdentifiers(exp, type = "local") {},
2571
2589
  removeIdentifiers(exp) {},
2590
+ isSlotScopeIdentifier(name) {
2591
+ const scopes = context.identifierScopes[name];
2592
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
2593
+ },
2572
2594
  hoist(exp) {
2573
2595
  if (isString(exp)) exp = createSimpleExpression(exp);
2574
2596
  context.hoists.push(exp);
@@ -2932,6 +2954,7 @@ function genNode(node, context) {
2932
2954
  case 24: break;
2933
2955
  case 25: break;
2934
2956
  case 26: break;
2957
+ /* v8 ignore start */
2935
2958
  case 10: break;
2936
2959
  default: if (!!(process.env.NODE_ENV !== "production")) {
2937
2960
  assert(false, `unhandled codegen node type: ${node.type}`);
@@ -3152,7 +3175,7 @@ const transformExpression = (node, context) => {
3152
3175
  if (dir.type === 7 && dir.name !== "for") {
3153
3176
  const exp = dir.exp;
3154
3177
  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");
3178
+ 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
3179
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
3157
3180
  }
3158
3181
  }
@@ -3298,10 +3321,9 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
3298
3321
  const isTemplate = isTemplateNode(node);
3299
3322
  const memo = findDir(node, "memo");
3300
3323
  const keyProp = findProp(node, `key`, false, true);
3301
- const isDirKey = keyProp && keyProp.type === 7;
3324
+ keyProp && keyProp.type;
3302
3325
  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;
3326
+ const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
3305
3327
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
3306
3328
  const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
3307
3329
  forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
@@ -4101,7 +4123,7 @@ function rewriteFilter(node, context) {
4101
4123
  const child = node.children[i];
4102
4124
  if (typeof child !== "object") continue;
4103
4125
  if (child.type === 4) parseFilter(child, context);
4104
- else if (child.type === 8) rewriteFilter(node, context);
4126
+ else if (child.type === 8) rewriteFilter(child, context);
4105
4127
  else if (child.type === 5) rewriteFilter(child.content, context);
4106
4128
  }
4107
4129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.6.0-beta.9",
3
+ "version": "3.6.0-rc.1",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -46,13 +46,13 @@
46
46
  },
47
47
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
48
48
  "dependencies": {
49
- "@babel/parser": "^7.29.2",
49
+ "@babel/parser": "^7.29.7",
50
50
  "entities": "^7.0.1",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.1",
53
- "@vue/shared": "3.6.0-beta.9"
53
+ "@vue/shared": "3.6.0-rc.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@babel/types": "^7.29.0"
56
+ "@babel/types": "^7.29.7"
57
57
  }
58
58
  }