@wevu/compiler 6.16.3 → 6.16.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.
- package/dist/index.mjs +11 -8
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -6423,19 +6423,15 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6423
6423
|
let slotPropsExp = collectSlotBindingExpression(node, context);
|
|
6424
6424
|
let fallbackContent = "";
|
|
6425
6425
|
if (node.children.length > 0) fallbackContent = node.children.map((child) => transformNode(child, context)).join("");
|
|
6426
|
-
if (slotPropsExp && fallbackContent) {
|
|
6427
|
-
context.warnings.push("不支持作用域插槽的兜底内容,已忽略。");
|
|
6428
|
-
fallbackContent = "";
|
|
6429
|
-
}
|
|
6430
6426
|
const slotAttrs = [];
|
|
6431
6427
|
const nameAttr = renderSlotNameAttribute(slotNameInfo, context, "name");
|
|
6432
6428
|
if (nameAttr) slotAttrs.push(nameAttr);
|
|
6433
6429
|
const slotAttrString = slotAttrs.length ? ` ${slotAttrs.join(" ")}` : "";
|
|
6434
6430
|
let slotTag = `<slot${slotAttrString} />`;
|
|
6431
|
+
const slotPresentExp = fallbackContent ? createSlotPresenceExpression(slotNameInfo) : void 0;
|
|
6435
6432
|
if (fallbackContent) {
|
|
6436
|
-
const slotPresentExp = createSlotPresenceExpression(slotNameInfo);
|
|
6437
6433
|
if (!slotPropsExp && slotPresentExp) slotTag = `${context.platform.wrapIf(slotPresentExp, slotTag, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
|
|
6438
|
-
else slotTag = `<slot${slotAttrString}>${fallbackContent}</slot>`;
|
|
6434
|
+
else if (!slotPropsExp) slotTag = `<slot${slotAttrString}>${fallbackContent}</slot>`;
|
|
6439
6435
|
}
|
|
6440
6436
|
if (!slotPropsExp && (context.scopedSlotsRequireProps || slotNameInfo.type !== "default")) return slotTag;
|
|
6441
6437
|
const genericKey = `scoped-slots-${resolveSlotKey(context, slotNameInfo)}`;
|
|
@@ -6448,7 +6444,9 @@ function transformSlotElement(node, context, transformNode) {
|
|
|
6448
6444
|
];
|
|
6449
6445
|
if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
|
|
6450
6446
|
const scopedTag = `<${genericKey}${scopedAttrs.length ? ` ${scopedAttrs.join(" ")}` : ""} />`;
|
|
6451
|
-
|
|
6447
|
+
const projectedContent = `${slotTag}${scopedTag}`;
|
|
6448
|
+
if (fallbackContent && slotPresentExp) return `${context.platform.wrapIf(slotPresentExp, projectedContent, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
|
|
6449
|
+
return projectedContent;
|
|
6452
6450
|
}
|
|
6453
6451
|
function transformSlotElementPlain(node, context, transformNode) {
|
|
6454
6452
|
const slotNameInfo = resolveSlotNameFromSlotElement(node);
|
|
@@ -6485,6 +6483,11 @@ function hasDirectComponentSlotChild(children, context) {
|
|
|
6485
6483
|
return /^[A-Z]/.test(child.tag);
|
|
6486
6484
|
});
|
|
6487
6485
|
}
|
|
6486
|
+
function shouldAugmentPlainDefaultSlot(decl, context) {
|
|
6487
|
+
if (context.scopedSlotsRequireProps || !decl.implicitDefault) return false;
|
|
6488
|
+
if (context.scopedSlotsCompiler === "augmented") return true;
|
|
6489
|
+
return hasDirectComponentSlotChild(decl.children, context);
|
|
6490
|
+
}
|
|
6488
6491
|
function resolveTemplateSlotCondition(node, context) {
|
|
6489
6492
|
const ifDirective = node.props.find((prop) => prop.type === NodeTypes.DIRECTIVE && prop.name === "if" && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION);
|
|
6490
6493
|
const rawExp = ifDirective?.exp?.type === NodeTypes.SIMPLE_EXPRESSION ? ifDirective.exp.content : "";
|
|
@@ -6564,7 +6567,7 @@ function transformComponentWithSlots(node, context, transformNode, options) {
|
|
|
6564
6567
|
}
|
|
6565
6568
|
const scopedSlotDeclarations = [];
|
|
6566
6569
|
const plainSlotDeclarations = [];
|
|
6567
|
-
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 ||
|
|
6570
|
+
for (const decl of slotDeclarations) if (Object.keys(decl.props).length > 0 || shouldAugmentPlainDefaultSlot(decl, context)) scopedSlotDeclarations.push(decl);
|
|
6568
6571
|
else plainSlotDeclarations.push(decl);
|
|
6569
6572
|
const slotNames = [];
|
|
6570
6573
|
const slotGenericAttrs = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.4",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@vue/compiler-core": "^3.5.33",
|
|
46
46
|
"@vue/compiler-dom": "^3.5.33",
|
|
47
47
|
"comment-json": "^5.0.0",
|
|
48
|
-
"lru-cache": "^11.3.
|
|
48
|
+
"lru-cache": "^11.3.6",
|
|
49
49
|
"magic-string": "^0.30.21",
|
|
50
50
|
"merge": "^2.1.1",
|
|
51
51
|
"pathe": "^2.0.3",
|
|
52
52
|
"vue": "^3.5.33",
|
|
53
53
|
"@weapp-core/constants": "^0.1.4",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.16.
|
|
55
|
+
"@weapp-vite/ast": "6.16.4",
|
|
56
56
|
"rolldown-require": "2.0.15"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|