@vue/compiler-core 3.6.0-beta.9 → 3.6.0-rc.2
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-
|
|
2
|
+
* @vue/compiler-core v3.6.0-rc.2
|
|
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) {
|
|
@@ -3174,8 +3189,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3174
3189
|
imports: [],
|
|
3175
3190
|
cached: [],
|
|
3176
3191
|
constantCache: /* @__PURE__ */ new WeakMap(),
|
|
3192
|
+
vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
|
|
3177
3193
|
temps: 0,
|
|
3178
3194
|
identifiers: Object.create(null),
|
|
3195
|
+
identifierScopes: Object.create(null),
|
|
3179
3196
|
scopes: {
|
|
3180
3197
|
vFor: 0,
|
|
3181
3198
|
vSlot: 0,
|
|
@@ -3226,16 +3243,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3226
3243
|
context.parent.children.splice(removalIndex, 1);
|
|
3227
3244
|
},
|
|
3228
3245
|
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);
|
|
3246
|
+
addIdentifiers(exp, type = "local") {
|
|
3247
|
+
if ((0, _vue_shared.isString)(exp)) addId(exp, type);
|
|
3248
|
+
else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
|
|
3249
|
+
else if (exp.type === 4) addId(exp.content, type);
|
|
3233
3250
|
},
|
|
3234
3251
|
removeIdentifiers(exp) {
|
|
3235
3252
|
if ((0, _vue_shared.isString)(exp)) removeId(exp);
|
|
3236
3253
|
else if (exp.identifiers) exp.identifiers.forEach(removeId);
|
|
3237
3254
|
else if (exp.type === 4) removeId(exp.content);
|
|
3238
3255
|
},
|
|
3256
|
+
isSlotScopeIdentifier(name) {
|
|
3257
|
+
const scopes = context.identifierScopes[name];
|
|
3258
|
+
return scopes ? scopes[scopes.length - 1] === "slot" : false;
|
|
3259
|
+
},
|
|
3239
3260
|
hoist(exp) {
|
|
3240
3261
|
if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
|
|
3241
3262
|
context.hoists.push(exp);
|
|
@@ -3250,13 +3271,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3250
3271
|
}
|
|
3251
3272
|
};
|
|
3252
3273
|
context.filters = /* @__PURE__ */ new Set();
|
|
3253
|
-
function addId(id) {
|
|
3254
|
-
const { identifiers } = context;
|
|
3274
|
+
function addId(id, type) {
|
|
3275
|
+
const { identifiers, identifierScopes } = context;
|
|
3255
3276
|
if (identifiers[id] === void 0) identifiers[id] = 0;
|
|
3256
3277
|
identifiers[id]++;
|
|
3278
|
+
(identifierScopes[id] || (identifierScopes[id] = [])).push(type);
|
|
3257
3279
|
}
|
|
3258
3280
|
function removeId(id) {
|
|
3259
3281
|
context.identifiers[id]--;
|
|
3282
|
+
const scopes = context.identifierScopes[id];
|
|
3283
|
+
if (scopes) scopes.pop();
|
|
3260
3284
|
}
|
|
3261
3285
|
return context;
|
|
3262
3286
|
}
|
|
@@ -3693,6 +3717,7 @@ function genNode(node, context) {
|
|
|
3693
3717
|
case 26:
|
|
3694
3718
|
genReturnStatement(node, context);
|
|
3695
3719
|
break;
|
|
3720
|
+
/* v8 ignore start */
|
|
3696
3721
|
case 10: break;
|
|
3697
3722
|
default:
|
|
3698
3723
|
assert(false, `unhandled codegen node type: ${node.type}`);
|
|
@@ -3945,7 +3970,7 @@ const transformExpression = (node, context) => {
|
|
|
3945
3970
|
if (dir.type === 7 && dir.name !== "for") {
|
|
3946
3971
|
const exp = dir.exp;
|
|
3947
3972
|
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");
|
|
3973
|
+
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
3974
|
if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
|
|
3950
3975
|
}
|
|
3951
3976
|
}
|
|
@@ -4203,11 +4228,11 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
|
|
|
4203
4228
|
const keyProp = findProp(node, `key`, false, true);
|
|
4204
4229
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
4205
4230
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
if (isTemplate) {
|
|
4209
|
-
|
|
4210
|
-
if (
|
|
4231
|
+
const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4232
|
+
if (isTemplate && memo) memo.exp = processExpression(memo.exp, context);
|
|
4233
|
+
if ((isTemplate || memo) && keyProperty && isDirKey) {
|
|
4234
|
+
keyExp = keyProp.exp = keyProperty.value = processExpression(keyProperty.value, context);
|
|
4235
|
+
if (memo) context.vForMemoKeyedNodes.add(node);
|
|
4211
4236
|
}
|
|
4212
4237
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
4213
4238
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
@@ -4338,7 +4363,7 @@ const trackSlotScopes = (node, context) => {
|
|
|
4338
4363
|
const vSlot = findDir(node, "slot");
|
|
4339
4364
|
if (vSlot) {
|
|
4340
4365
|
const slotProps = vSlot.exp;
|
|
4341
|
-
if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
|
|
4366
|
+
if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
|
|
4342
4367
|
context.scopes.vSlot++;
|
|
4343
4368
|
return () => {
|
|
4344
4369
|
if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
|
|
@@ -4559,6 +4584,15 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4559
4584
|
if (!ssr) context.helper(builtIn);
|
|
4560
4585
|
return builtIn;
|
|
4561
4586
|
}
|
|
4587
|
+
{
|
|
4588
|
+
const fromScope = resolveSlotScopeReference(tag, context);
|
|
4589
|
+
if (fromScope) return fromScope;
|
|
4590
|
+
const dotIndex = tag.indexOf(".");
|
|
4591
|
+
if (dotIndex > 0) {
|
|
4592
|
+
const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
|
|
4593
|
+
if (ns) return ns + tag.slice(dotIndex);
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4562
4596
|
{
|
|
4563
4597
|
const fromSetup = resolveSetupReference(tag, context);
|
|
4564
4598
|
if (fromSetup) return fromSetup;
|
|
@@ -4577,6 +4611,14 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4577
4611
|
context.components.add(tag);
|
|
4578
4612
|
return toValidAssetId(tag, `component`);
|
|
4579
4613
|
}
|
|
4614
|
+
function resolveSlotScopeReference(name, context) {
|
|
4615
|
+
const camelName = (0, _vue_shared.camelize)(name);
|
|
4616
|
+
const PascalName = (0, _vue_shared.capitalize)(camelName);
|
|
4617
|
+
const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
|
|
4618
|
+
if (isInSlotScope(name)) return name;
|
|
4619
|
+
if (isInSlotScope(camelName)) return camelName;
|
|
4620
|
+
if (isInSlotScope(PascalName)) return PascalName;
|
|
4621
|
+
}
|
|
4580
4622
|
function resolveSetupReference(name, context) {
|
|
4581
4623
|
const bindings = context.bindingMetadata;
|
|
4582
4624
|
if (!bindings || bindings.__isScriptSetup === false) return;
|
|
@@ -5102,7 +5144,7 @@ function rewriteFilter(node, context) {
|
|
|
5102
5144
|
const child = node.children[i];
|
|
5103
5145
|
if (typeof child !== "object") continue;
|
|
5104
5146
|
if (child.type === 4) parseFilter(child, context);
|
|
5105
|
-
else if (child.type === 8) rewriteFilter(
|
|
5147
|
+
else if (child.type === 8) rewriteFilter(child, context);
|
|
5106
5148
|
else if (child.type === 5) rewriteFilter(child.content, context);
|
|
5107
5149
|
}
|
|
5108
5150
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.6.0-
|
|
2
|
+
* @vue/compiler-core v3.6.0-rc.2
|
|
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) {
|
|
@@ -3153,8 +3168,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3153
3168
|
imports: [],
|
|
3154
3169
|
cached: [],
|
|
3155
3170
|
constantCache: /* @__PURE__ */ new WeakMap(),
|
|
3171
|
+
vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
|
|
3156
3172
|
temps: 0,
|
|
3157
3173
|
identifiers: Object.create(null),
|
|
3174
|
+
identifierScopes: Object.create(null),
|
|
3158
3175
|
scopes: {
|
|
3159
3176
|
vFor: 0,
|
|
3160
3177
|
vSlot: 0,
|
|
@@ -3199,16 +3216,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3199
3216
|
context.parent.children.splice(removalIndex, 1);
|
|
3200
3217
|
},
|
|
3201
3218
|
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);
|
|
3219
|
+
addIdentifiers(exp, type = "local") {
|
|
3220
|
+
if ((0, _vue_shared.isString)(exp)) addId(exp, type);
|
|
3221
|
+
else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
|
|
3222
|
+
else if (exp.type === 4) addId(exp.content, type);
|
|
3206
3223
|
},
|
|
3207
3224
|
removeIdentifiers(exp) {
|
|
3208
3225
|
if ((0, _vue_shared.isString)(exp)) removeId(exp);
|
|
3209
3226
|
else if (exp.identifiers) exp.identifiers.forEach(removeId);
|
|
3210
3227
|
else if (exp.type === 4) removeId(exp.content);
|
|
3211
3228
|
},
|
|
3229
|
+
isSlotScopeIdentifier(name) {
|
|
3230
|
+
const scopes = context.identifierScopes[name];
|
|
3231
|
+
return scopes ? scopes[scopes.length - 1] === "slot" : false;
|
|
3232
|
+
},
|
|
3212
3233
|
hoist(exp) {
|
|
3213
3234
|
if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
|
|
3214
3235
|
context.hoists.push(exp);
|
|
@@ -3223,13 +3244,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
3223
3244
|
}
|
|
3224
3245
|
};
|
|
3225
3246
|
context.filters = /* @__PURE__ */ new Set();
|
|
3226
|
-
function addId(id) {
|
|
3227
|
-
const { identifiers } = context;
|
|
3247
|
+
function addId(id, type) {
|
|
3248
|
+
const { identifiers, identifierScopes } = context;
|
|
3228
3249
|
if (identifiers[id] === void 0) identifiers[id] = 0;
|
|
3229
3250
|
identifiers[id]++;
|
|
3251
|
+
(identifierScopes[id] || (identifierScopes[id] = [])).push(type);
|
|
3230
3252
|
}
|
|
3231
3253
|
function removeId(id) {
|
|
3232
3254
|
context.identifiers[id]--;
|
|
3255
|
+
const scopes = context.identifierScopes[id];
|
|
3256
|
+
if (scopes) scopes.pop();
|
|
3233
3257
|
}
|
|
3234
3258
|
return context;
|
|
3235
3259
|
}
|
|
@@ -3661,6 +3685,7 @@ function genNode(node, context) {
|
|
|
3661
3685
|
case 26:
|
|
3662
3686
|
genReturnStatement(node, context);
|
|
3663
3687
|
break;
|
|
3688
|
+
/* v8 ignore start */
|
|
3664
3689
|
case 10: break;
|
|
3665
3690
|
default:
|
|
3666
3691
|
}
|
|
@@ -3910,7 +3935,7 @@ const transformExpression = (node, context) => {
|
|
|
3910
3935
|
if (dir.type === 7 && dir.name !== "for") {
|
|
3911
3936
|
const exp = dir.exp;
|
|
3912
3937
|
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");
|
|
3938
|
+
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
3939
|
if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
|
|
3915
3940
|
}
|
|
3916
3941
|
}
|
|
@@ -4161,11 +4186,11 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
|
|
|
4161
4186
|
const keyProp = findProp(node, `key`, false, true);
|
|
4162
4187
|
const isDirKey = keyProp && keyProp.type === 7;
|
|
4163
4188
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
if (isTemplate) {
|
|
4167
|
-
|
|
4168
|
-
if (
|
|
4189
|
+
const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
4190
|
+
if (isTemplate && memo) memo.exp = processExpression(memo.exp, context);
|
|
4191
|
+
if ((isTemplate || memo) && keyProperty && isDirKey) {
|
|
4192
|
+
keyExp = keyProp.exp = keyProperty.value = processExpression(keyProperty.value, context);
|
|
4193
|
+
if (memo) context.vForMemoKeyedNodes.add(node);
|
|
4169
4194
|
}
|
|
4170
4195
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
4171
4196
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
@@ -4296,7 +4321,7 @@ const trackSlotScopes = (node, context) => {
|
|
|
4296
4321
|
const vSlot = findDir(node, "slot");
|
|
4297
4322
|
if (vSlot) {
|
|
4298
4323
|
const slotProps = vSlot.exp;
|
|
4299
|
-
if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
|
|
4324
|
+
if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
|
|
4300
4325
|
context.scopes.vSlot++;
|
|
4301
4326
|
return () => {
|
|
4302
4327
|
if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
|
|
@@ -4512,6 +4537,15 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4512
4537
|
if (!ssr) context.helper(builtIn);
|
|
4513
4538
|
return builtIn;
|
|
4514
4539
|
}
|
|
4540
|
+
{
|
|
4541
|
+
const fromScope = resolveSlotScopeReference(tag, context);
|
|
4542
|
+
if (fromScope) return fromScope;
|
|
4543
|
+
const dotIndex = tag.indexOf(".");
|
|
4544
|
+
if (dotIndex > 0) {
|
|
4545
|
+
const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
|
|
4546
|
+
if (ns) return ns + tag.slice(dotIndex);
|
|
4547
|
+
}
|
|
4548
|
+
}
|
|
4515
4549
|
{
|
|
4516
4550
|
const fromSetup = resolveSetupReference(tag, context);
|
|
4517
4551
|
if (fromSetup) return fromSetup;
|
|
@@ -4530,6 +4564,14 @@ function resolveComponentType(node, context, ssr = false) {
|
|
|
4530
4564
|
context.components.add(tag);
|
|
4531
4565
|
return toValidAssetId(tag, `component`);
|
|
4532
4566
|
}
|
|
4567
|
+
function resolveSlotScopeReference(name, context) {
|
|
4568
|
+
const camelName = (0, _vue_shared.camelize)(name);
|
|
4569
|
+
const PascalName = (0, _vue_shared.capitalize)(camelName);
|
|
4570
|
+
const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
|
|
4571
|
+
if (isInSlotScope(name)) return name;
|
|
4572
|
+
if (isInSlotScope(camelName)) return camelName;
|
|
4573
|
+
if (isInSlotScope(PascalName)) return PascalName;
|
|
4574
|
+
}
|
|
4533
4575
|
function resolveSetupReference(name, context) {
|
|
4534
4576
|
const bindings = context.bindingMetadata;
|
|
4535
4577
|
if (!bindings || bindings.__isScriptSetup === false) return;
|
|
@@ -5047,7 +5089,7 @@ function rewriteFilter(node, context) {
|
|
|
5047
5089
|
const child = node.children[i];
|
|
5048
5090
|
if (typeof child !== "object") continue;
|
|
5049
5091
|
if (child.type === 4) parseFilter(child, context);
|
|
5050
|
-
else if (child.type === 8) rewriteFilter(
|
|
5092
|
+
else if (child.type === 8) rewriteFilter(child, context);
|
|
5051
5093
|
else if (child.type === 5) rewriteFilter(child.content, context);
|
|
5052
5094
|
}
|
|
5053
5095
|
}
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -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;
|
|
@@ -497,7 +503,7 @@ export interface DirectiveArgumentNode extends ArrayExpression {
|
|
|
497
503
|
}
|
|
498
504
|
export interface RenderSlotCall extends CallExpression {
|
|
499
505
|
callee: typeof RENDER_SLOT;
|
|
500
|
-
arguments: [string, string | ExpressionNode] | [string, string | ExpressionNode, PropsExpression] | [string, string | ExpressionNode, PropsExpression | "{}",
|
|
506
|
+
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
507
|
}
|
|
502
508
|
export type SlotsExpression = SlotsObjectExpression | DynamicSlotsExpression;
|
|
503
509
|
export interface SlotsObjectExpression extends ObjectExpression {
|
|
@@ -976,7 +982,7 @@ export type CompilerOptions = ParserOptions & TransformOptions & CodegenOptions;
|
|
|
976
982
|
*
|
|
977
983
|
* Since TS 5.3, dts generation starts to strangely include broken triple slash
|
|
978
984
|
* references for source-map-js, so we are inlining all source map related types
|
|
979
|
-
* here to
|
|
985
|
+
* here to workaround that.
|
|
980
986
|
*/
|
|
981
987
|
export interface CodegenSourceMapGenerator {
|
|
982
988
|
setSourceContent(sourceFile: string, sourceContent: string): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.6.0-
|
|
2
|
+
* @vue/compiler-core v3.6.0-rc.2
|
|
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) {
|
|
@@ -2512,8 +2527,10 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
2512
2527
|
imports: [],
|
|
2513
2528
|
cached: [],
|
|
2514
2529
|
constantCache: /* @__PURE__ */ new WeakMap(),
|
|
2530
|
+
vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
|
|
2515
2531
|
temps: 0,
|
|
2516
2532
|
identifiers: Object.create(null),
|
|
2533
|
+
identifierScopes: Object.create(null),
|
|
2517
2534
|
scopes: {
|
|
2518
2535
|
vFor: 0,
|
|
2519
2536
|
vSlot: 0,
|
|
@@ -2567,8 +2584,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
|
|
|
2567
2584
|
context.parent.children.splice(removalIndex, 1);
|
|
2568
2585
|
},
|
|
2569
2586
|
onNodeRemoved: NOOP,
|
|
2570
|
-
addIdentifiers(exp) {},
|
|
2587
|
+
addIdentifiers(exp, type = "local") {},
|
|
2571
2588
|
removeIdentifiers(exp) {},
|
|
2589
|
+
isSlotScopeIdentifier(name) {
|
|
2590
|
+
const scopes = context.identifierScopes[name];
|
|
2591
|
+
return scopes ? scopes[scopes.length - 1] === "slot" : false;
|
|
2592
|
+
},
|
|
2572
2593
|
hoist(exp) {
|
|
2573
2594
|
if (isString(exp)) exp = createSimpleExpression(exp);
|
|
2574
2595
|
context.hoists.push(exp);
|
|
@@ -2932,6 +2953,7 @@ function genNode(node, context) {
|
|
|
2932
2953
|
case 24: break;
|
|
2933
2954
|
case 25: break;
|
|
2934
2955
|
case 26: break;
|
|
2956
|
+
/* v8 ignore start */
|
|
2935
2957
|
case 10: break;
|
|
2936
2958
|
default: if (!!(process.env.NODE_ENV !== "production")) {
|
|
2937
2959
|
assert(false, `unhandled codegen node type: ${node.type}`);
|
|
@@ -3152,7 +3174,7 @@ const transformExpression = (node, context) => {
|
|
|
3152
3174
|
if (dir.type === 7 && dir.name !== "for") {
|
|
3153
3175
|
const exp = dir.exp;
|
|
3154
3176
|
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");
|
|
3177
|
+
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
3178
|
if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
|
|
3157
3179
|
}
|
|
3158
3180
|
}
|
|
@@ -3298,10 +3320,9 @@ const transformFor = createStructuralDirectiveTransform("for", (node, dir, conte
|
|
|
3298
3320
|
const isTemplate = isTemplateNode(node);
|
|
3299
3321
|
const memo = findDir(node, "memo");
|
|
3300
3322
|
const keyProp = findProp(node, `key`, false, true);
|
|
3301
|
-
|
|
3323
|
+
keyProp && keyProp.type;
|
|
3302
3324
|
let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
|
|
3303
|
-
|
|
3304
|
-
const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
3325
|
+
const keyProperty = keyExp ? createObjectProperty(`key`, keyExp) : null;
|
|
3305
3326
|
const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
|
|
3306
3327
|
const fragmentFlag = isStableFragment ? 64 : keyProp ? 128 : 256;
|
|
3307
3328
|
forNode.codegenNode = createVNodeCall(context, helper(FRAGMENT), void 0, renderExp, fragmentFlag, void 0, void 0, true, !isStableFragment, false, node.loc);
|
|
@@ -4101,7 +4122,7 @@ function rewriteFilter(node, context) {
|
|
|
4101
4122
|
const child = node.children[i];
|
|
4102
4123
|
if (typeof child !== "object") continue;
|
|
4103
4124
|
if (child.type === 4) parseFilter(child, context);
|
|
4104
|
-
else if (child.type === 8) rewriteFilter(
|
|
4125
|
+
else if (child.type === 8) rewriteFilter(child, context);
|
|
4105
4126
|
else if (child.type === 5) rewriteFilter(child.content, context);
|
|
4106
4127
|
}
|
|
4107
4128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.6.0-
|
|
3
|
+
"version": "3.6.0-rc.2",
|
|
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.
|
|
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-
|
|
53
|
+
"@vue/shared": "3.6.0-rc.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/types": "^7.29.
|
|
56
|
+
"@babel/types": "^7.29.7"
|
|
57
57
|
}
|
|
58
58
|
}
|