讨论加特殊图标

This commit is contained in:
DESKTOP-RQ919RC\Pc
2025-03-21 15:55:33 +08:00
parent 7cc2b264d2
commit 27f3bcacbf
272 changed files with 18932 additions and 35894 deletions

View File

@@ -1,3 +1,8 @@
/**
* @vue/compiler-ssr v3.5.13
* (c) 2018-present Yuxi (Evan) You and Vue contributors
* @license MIT
**/
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
@@ -16,11 +21,17 @@ const SSR_RENDER_ATTRS = Symbol(`ssrRenderAttrs`);
const SSR_RENDER_ATTR = Symbol(`ssrRenderAttr`);
const SSR_RENDER_DYNAMIC_ATTR = Symbol(`ssrRenderDynamicAttr`);
const SSR_RENDER_LIST = Symbol(`ssrRenderList`);
const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(`ssrIncludeBooleanAttr`);
const SSR_INCLUDE_BOOLEAN_ATTR = Symbol(
`ssrIncludeBooleanAttr`
);
const SSR_LOOSE_EQUAL = Symbol(`ssrLooseEqual`);
const SSR_LOOSE_CONTAIN = Symbol(`ssrLooseContain`);
const SSR_RENDER_DYNAMIC_MODEL = Symbol(`ssrRenderDynamicModel`);
const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(`ssrGetDynamicModelProps`);
const SSR_RENDER_DYNAMIC_MODEL = Symbol(
`ssrRenderDynamicModel`
);
const SSR_GET_DYNAMIC_MODEL_PROPS = Symbol(
`ssrGetDynamicModelProps`
);
const SSR_RENDER_TELEPORT = Symbol(`ssrRenderTeleport`);
const SSR_RENDER_SUSPENSE = Symbol(`ssrRenderSuspense`);
const SSR_GET_DIRECTIVE_PROPS = Symbol(`ssrGetDirectiveProps`);
@@ -51,7 +62,7 @@ const ssrTransformIf = compilerDom.createStructuralDirectiveTransform(
/^(if|else|else-if)$/,
compilerDom.processIf
);
function ssrProcessIf(node, context, disableNestedFragments = false) {
function ssrProcessIf(node, context, disableNestedFragments = false, disableComment = false) {
const [rootBranch] = node.branches;
const ifStatement = compilerDom.createIfStatement(
rootBranch.condition,
@@ -75,7 +86,7 @@ function ssrProcessIf(node, context, disableNestedFragments = false) {
currentIf.alternate = branchBlockStatement;
}
}
if (!currentIf.alternate) {
if (!currentIf.alternate && !disableComment) {
currentIf.alternate = compilerDom.createBlockStatement([
compilerDom.createCallExpression(`_push`, ["`<!---->`"])
]);
@@ -88,10 +99,7 @@ function processIfBranch(branch, context, disableNestedFragments = false) {
return processChildrenAsStatement(branch, context, needFragmentWrapper);
}
const ssrTransformFor = compilerDom.createStructuralDirectiveTransform(
"for",
compilerDom.processFor
);
const ssrTransformFor = compilerDom.createStructuralDirectiveTransform("for", compilerDom.processFor);
function ssrProcessFor(node, context, disableNestedFragments = false) {
const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== 1);
const renderLoop = compilerDom.createFunctionExpression(
@@ -132,13 +140,20 @@ const ssrTransformSlotOutlet = (node, context) => {
args.push(`"${context.scopeId}-s"`);
}
let method = SSR_RENDER_SLOT;
const parent = context.parent;
if (parent && parent.type === 1 && parent.tagType === 1 && compilerDom.resolveComponentType(parent, context, true) === compilerDom.TRANSITION && parent.children.filter((c) => c.type === 1).length === 1) {
method = SSR_RENDER_SLOT_INNER;
if (!(context.scopeId && context.slotted !== false)) {
args.push("null");
let parent = context.parent;
if (parent) {
const children = parent.children;
if (parent.type === 10) {
parent = context.grandParent;
}
let componentType;
if (parent.type === 1 && parent.tagType === 1 && ((componentType = compilerDom.resolveComponentType(parent, context, true)) === compilerDom.TRANSITION || componentType === compilerDom.TRANSITION_GROUP) && children.filter((c) => c.type === 1).length === 1) {
method = SSR_RENDER_SLOT_INNER;
if (!(context.scopeId && context.slotted !== false)) {
args.push("null");
}
args.push("true");
}
args.push("true");
}
node.ssrCodegenNode = compilerDom.createCallExpression(context.helper(method), args);
}
@@ -292,7 +307,6 @@ const ssrTransformElement = (node, context) => {
false,
false,
true
/* ssr */
);
if (props || directives.length) {
const mergedProps = buildSSRProps(props, directives, context);
@@ -348,6 +362,28 @@ const ssrTransformElement = (node, context) => {
])
];
}
} else if (directives.length && !node.children.length) {
const vText = compilerDom.findDir(node, "text");
if (!vText) {
const tempId = `_temp${context.temps++}`;
propsExp.arguments = [
compilerDom.createAssignmentExpression(
compilerDom.createSimpleExpression(tempId, false),
mergedProps
)
];
rawChildrenMap.set(
node,
compilerDom.createConditionalExpression(
compilerDom.createSimpleExpression(`"textContent" in ${tempId}`, false),
compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [
compilerDom.createSimpleExpression(`${tempId}.textContent`, false)
]),
compilerDom.createSimpleExpression(`${tempId}.innerHTML ?? ''`, false),
false
)
);
}
}
if (needTagForRuntime) {
propsExp.arguments.push(`"${node.tag}"`);
@@ -365,7 +401,10 @@ const ssrTransformElement = (node, context) => {
}
if (prop.type === 7) {
if (prop.name === "html" && prop.exp) {
rawChildrenMap.set(node, prop.exp);
rawChildrenMap.set(
node,
compilerDom.createCompoundExpression([`(`, prop.exp, `) ?? ''`])
);
} else if (prop.name === "text" && prop.exp) {
node.children = [compilerDom.createInterpolation(prop.exp, prop.loc)];
} else if (prop.name === "slot") {
@@ -428,7 +467,6 @@ const ssrTransformElement = (node, context) => {
compilerDom.createSimpleExpression(" " + attrName, true),
compilerDom.createSimpleExpression("", true),
false
/* no newline */
)
);
} else if (shared.isSSRSafeAttrName(attrName)) {
@@ -463,13 +501,14 @@ const ssrTransformElement = (node, context) => {
}
}
} else {
if (node.tag === "textarea" && prop.name === "value" && prop.value) {
const name = prop.name;
if (node.tag === "textarea" && name === "value" && prop.value) {
rawChildrenMap.set(node, shared.escapeHtml(prop.value.content));
} else if (!needMergeProps) {
if (prop.name === "key" || prop.name === "ref") {
if (name === "key" || name === "ref") {
continue;
}
if (prop.name === "class" && prop.value) {
if (name === "class" && prop.value) {
staticClassBinding = JSON.stringify(prop.value.content);
}
openTag.push(
@@ -573,7 +612,6 @@ function ssrTransformTransitionGroup(node, context) {
true,
false,
true
/* ssr (skip event listeners) */
);
let propsExp = null;
if (props || directives.length) {
@@ -613,6 +651,13 @@ function ssrProcessTransitionGroup(node, context) {
* be patched using the same key map) so we need to account for that here
* by disabling nested fragment wrappers from being generated.
*/
true,
/**
* TransitionGroup filters out comment children at runtime and thus
* doesn't expect comments to be present during hydration. We need to
* account for that by disabling the empty comment that is otherwise
* rendered for a falsy v-if that has no v-else specified. (#6715)
*/
true
);
context.pushStringPart(`</`);
@@ -627,11 +672,11 @@ function ssrProcessTransitionGroup(node, context) {
context.pushStringPart(` ${scopeId}`);
}
context.pushStringPart(`>`);
processChildren(node, context, false, true);
processChildren(node, context, false, true, true);
context.pushStringPart(`</${tag.value.content}>`);
}
} else {
processChildren(node, context, true, true);
processChildren(node, context, true, true, true);
}
}
@@ -777,7 +822,6 @@ function ssrProcessComponent(node, context, parent) {
context,
false,
true
/* withSlotScopeId */
),
vnodeBranch
);
@@ -801,7 +845,7 @@ const vnodeDirectiveTransforms = {
...baseDirectiveTransforms,
...compilerDom.DOMDirectiveTransforms
};
function createVNodeSlotBranch(props, vForExp, children, parentContext) {
function createVNodeSlotBranch(slotProps, vFor, children, parentContext) {
const rawOptions = rawOptionsMap.get(parentContext.root);
const subOptions = {
...rawOptions,
@@ -815,32 +859,26 @@ function createVNodeSlotBranch(props, vForExp, children, parentContext) {
...rawOptions.directiveTransforms || {}
}
};
const wrapperProps = [];
if (slotProps) {
wrapperProps.push({
type: 7,
name: "slot",
exp: slotProps,
arg: void 0,
modifiers: [],
loc: compilerDom.locStub
});
}
if (vFor) {
wrapperProps.push(shared.extend({}, vFor));
}
const wrapperNode = {
type: 1,
ns: 0,
tag: "template",
tagType: 3,
isSelfClosing: false,
// important: provide v-slot="props" and v-for="exp" on the wrapper for
// proper scope analysis
props: [
{
type: 7,
name: "slot",
exp: props,
arg: void 0,
modifiers: [],
loc: compilerDom.locStub
},
{
type: 7,
name: "for",
exp: vForExp,
arg: void 0,
modifiers: [],
loc: compilerDom.locStub
}
],
props: wrapperProps,
children,
loc: compilerDom.locStub,
codegenNode: void 0
@@ -874,7 +912,7 @@ function subTransform(node, options, parentContext) {
function clone(v) {
if (shared.isArray(v)) {
return v.map(clone);
} else if (shared.isObject(v)) {
} else if (shared.isPlainObject(v)) {
const res = {};
for (const key in v) {
res[key] = clone(v[key]);
@@ -956,7 +994,7 @@ function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
withSlotScopeId
);
}
function processChildren(parent, context, asFragment = false, disableNestedFragments = false) {
function processChildren(parent, context, asFragment = false, disableNestedFragments = false, disableComment = false) {
if (asFragment) {
context.pushStringPart(`<!--[-->`);
}
@@ -992,15 +1030,19 @@ function processChildren(parent, context, asFragment = false, disableNestedFragm
context.pushStringPart(shared.escapeHtml(child.content));
break;
case 3:
context.pushStringPart(`<!--${child.content}-->`);
if (!disableComment) {
context.pushStringPart(`<!--${child.content}-->`);
}
break;
case 5:
context.pushStringPart(
compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [child.content])
compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [
child.content
])
);
break;
case 9:
ssrProcessIf(child, context, disableNestedFragments);
ssrProcessIf(child, context, disableNestedFragments, disableComment);
break;
case 11:
ssrProcessFor(child, context, disableNestedFragments);
@@ -1066,7 +1108,6 @@ const ssrTransformModel = (dir, node, context) => {
compilerDom.createSimpleExpression(" selected", true),
compilerDom.createSimpleExpression("", true),
false
/* no newline */
)
);
}
@@ -1158,11 +1199,18 @@ const ssrTransformModel = (dir, node, context) => {
checkDuplicatedValue();
node.children = [compilerDom.createInterpolation(model, model.loc)];
} else if (node.tag === "select") {
node.children.forEach((child) => {
if (child.type === 1) {
processOption(child);
}
});
const processChildren = (children) => {
children.forEach((child) => {
if (child.type === 1) {
processOption(child);
} else if (child.type === 11) {
processChildren(child.children);
} else if (child.type === 9) {
child.branches.forEach((b) => processChildren(b.children));
}
});
};
processChildren(node.children);
} else {
context.onError(
compilerDom.createDOMCompilerError(
@@ -1201,7 +1249,6 @@ const ssrTransformShow = (dir, node, context) => {
)
]),
false
/* no newline */
)
)
]
@@ -1214,7 +1261,7 @@ const ssrInjectFallthroughAttrs = (node, context) => {
if (node.type === 0) {
context.identifiers._attrs = 1;
}
if (node.type === 1 && node.tagType === 1 && (compilerDom.isBuiltInType(node.tag, "Transition") || compilerDom.isBuiltInType(node.tag, "KeepAlive"))) {
if (node.type === 1 && node.tagType === 1 && (node.tag === "transition" || node.tag === "Transition" || node.tag === "KeepAlive" || node.tag === "keep-alive")) {
const rootChildren = filterChild(context.root);
if (rootChildren.length === 1 && rootChildren[0] === node) {
if (hasSingleChild(node)) {
@@ -1231,8 +1278,7 @@ const ssrInjectFallthroughAttrs = (node, context) => {
let hasEncounteredIf = false;
for (const c of filterChild(parent)) {
if (c.type === 9 || c.type === 1 && compilerDom.findDir(c, "if")) {
if (hasEncounteredIf)
return;
if (hasEncounteredIf) return;
hasEncounteredIf = true;
} else if (
// node before v-if
@@ -1281,7 +1327,7 @@ const ssrInjectCssVars = (node, context) => {
};
function injectCssVars(node) {
if (node.type === 1 && (node.tagType === 0 || node.tagType === 1) && !compilerDom.findDir(node, "for")) {
if (compilerDom.isBuiltInType(node.tag, "Suspense")) {
if (node.tag === "suspense" || node.tag === "Suspense") {
for (const child of node.children) {
if (child.type === 1 && child.tagType === 3) {
child.children.forEach(injectCssVars);
@@ -1302,10 +1348,9 @@ function injectCssVars(node) {
}
}
function compile(template, options = {}) {
function compile(source, options = {}) {
options = {
...options,
// apply DOM-specific parsing options
...compilerDom.parserOptions,
ssr: true,
inSSR: true,
@@ -1316,7 +1361,7 @@ function compile(template, options = {}) {
cacheHandlers: false,
hoistStatic: false
};
const ast = compilerDom.baseParse(template, options);
const ast = typeof source === "string" ? compilerDom.baseParse(source, options) : source;
rawOptionsMap.set(ast, options);
compilerDom.transform(ast, {
...options,