@vue/compiler-ssr 3.2.36 → 3.2.39
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/compiler-ssr.cjs.js +84 -78
- package/package.json +3 -3
package/dist/compiler-ssr.cjs.js
CHANGED
|
@@ -79,9 +79,9 @@ function ssrProcessIf(node, context, disableNestedFragments = false) {
|
|
|
79
79
|
function processIfBranch(branch, context, disableNestedFragments = false) {
|
|
80
80
|
const { children } = branch;
|
|
81
81
|
const needFragmentWrapper = !disableNestedFragments &&
|
|
82
|
-
(children.length !== 1 || children[0].type !== 1 /* ELEMENT */) &&
|
|
82
|
+
(children.length !== 1 || children[0].type !== 1 /* NodeTypes.ELEMENT */) &&
|
|
83
83
|
// optimize away nested fragments when the only child is a ForNode
|
|
84
|
-
!(children.length === 1 && children[0].type === 11 /* FOR */);
|
|
84
|
+
!(children.length === 1 && children[0].type === 11 /* NodeTypes.FOR */);
|
|
85
85
|
return processChildrenAsStatement(branch, context, needFragmentWrapper);
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -91,7 +91,7 @@ const ssrTransformFor = compilerDom.createStructuralDirectiveTransform('for', co
|
|
|
91
91
|
// codegen nodes.
|
|
92
92
|
function ssrProcessFor(node, context, disableNestedFragments = false) {
|
|
93
93
|
const needFragmentWrapper = !disableNestedFragments &&
|
|
94
|
-
(node.children.length !== 1 || node.children[0].type !== 1 /* ELEMENT */);
|
|
94
|
+
(node.children.length !== 1 || node.children[0].type !== 1 /* NodeTypes.ELEMENT */);
|
|
95
95
|
const renderLoop = compilerDom.createFunctionExpression(compilerDom.createForLoopParams(node.parseResult));
|
|
96
96
|
renderLoop.body = processChildrenAsStatement(node, context, needFragmentWrapper);
|
|
97
97
|
// v-for always renders a fragment unless explicitly disabled
|
|
@@ -130,11 +130,15 @@ const ssrTransformSlotOutlet = (node, context) => {
|
|
|
130
130
|
// we need to avoid rendering the slot as a fragment.
|
|
131
131
|
const parent = context.parent;
|
|
132
132
|
if (parent &&
|
|
133
|
-
parent.type === 1 /* ELEMENT */ &&
|
|
134
|
-
parent.tagType === 1 /* COMPONENT */ &&
|
|
133
|
+
parent.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
134
|
+
parent.tagType === 1 /* ElementTypes.COMPONENT */ &&
|
|
135
135
|
compilerDom.resolveComponentType(parent, context, true) === compilerDom.TRANSITION &&
|
|
136
|
-
parent.children.filter(c => c.type === 1 /* ELEMENT */).length === 1) {
|
|
136
|
+
parent.children.filter(c => c.type === 1 /* NodeTypes.ELEMENT */).length === 1) {
|
|
137
137
|
method = SSR_RENDER_SLOT_INNER;
|
|
138
|
+
if (!(context.scopeId && context.slotted !== false)) {
|
|
139
|
+
args.push('null');
|
|
140
|
+
}
|
|
141
|
+
args.push('true');
|
|
138
142
|
}
|
|
139
143
|
node.ssrCodegenNode = compilerDom.createCallExpression(context.helper(method), args);
|
|
140
144
|
}
|
|
@@ -162,20 +166,20 @@ function createSSRCompilerError(code, loc) {
|
|
|
162
166
|
return compilerDom.createCompilerError(code, loc, SSRErrorMessages);
|
|
163
167
|
}
|
|
164
168
|
const SSRErrorMessages = {
|
|
165
|
-
[61 /* X_SSR_UNSAFE_ATTR_NAME */]: `Unsafe attribute name for SSR.`,
|
|
166
|
-
[62 /* X_SSR_NO_TELEPORT_TARGET */]: `Missing the 'to' prop on teleport element.`,
|
|
167
|
-
[63 /* X_SSR_INVALID_AST_NODE */]: `Invalid AST node during SSR transform.`
|
|
169
|
+
[61 /* SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME */]: `Unsafe attribute name for SSR.`,
|
|
170
|
+
[62 /* SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET */]: `Missing the 'to' prop on teleport element.`,
|
|
171
|
+
[63 /* SSRErrorCodes.X_SSR_INVALID_AST_NODE */]: `Invalid AST node during SSR transform.`
|
|
168
172
|
};
|
|
169
173
|
|
|
170
174
|
// Note: this is a 2nd-pass codegen transform.
|
|
171
175
|
function ssrProcessTeleport(node, context) {
|
|
172
176
|
const targetProp = compilerDom.findProp(node, 'to');
|
|
173
177
|
if (!targetProp) {
|
|
174
|
-
context.onError(createSSRCompilerError(62 /* X_SSR_NO_TELEPORT_TARGET */, node.loc));
|
|
178
|
+
context.onError(createSSRCompilerError(62 /* SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET */, node.loc));
|
|
175
179
|
return;
|
|
176
180
|
}
|
|
177
181
|
let target;
|
|
178
|
-
if (targetProp.type === 6 /* ATTRIBUTE */) {
|
|
182
|
+
if (targetProp.type === 6 /* NodeTypes.ATTRIBUTE */) {
|
|
179
183
|
target =
|
|
180
184
|
targetProp.value && compilerDom.createSimpleExpression(targetProp.value.content, true);
|
|
181
185
|
}
|
|
@@ -183,12 +187,12 @@ function ssrProcessTeleport(node, context) {
|
|
|
183
187
|
target = targetProp.exp;
|
|
184
188
|
}
|
|
185
189
|
if (!target) {
|
|
186
|
-
context.onError(createSSRCompilerError(62 /* X_SSR_NO_TELEPORT_TARGET */, targetProp.loc));
|
|
190
|
+
context.onError(createSSRCompilerError(62 /* SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET */, targetProp.loc));
|
|
187
191
|
return;
|
|
188
192
|
}
|
|
189
193
|
const disabledProp = compilerDom.findProp(node, 'disabled', false, true /* allow empty */);
|
|
190
194
|
const disabled = disabledProp
|
|
191
|
-
? disabledProp.type === 6 /* ATTRIBUTE */
|
|
195
|
+
? disabledProp.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
192
196
|
? `true`
|
|
193
197
|
: disabledProp.exp || `false`
|
|
194
198
|
: `false`;
|
|
@@ -253,8 +257,8 @@ function ssrProcessSuspense(node, context) {
|
|
|
253
257
|
// store the raw children so that they can be added in the 2nd pass.
|
|
254
258
|
const rawChildrenMap = new WeakMap();
|
|
255
259
|
const ssrTransformElement = (node, context) => {
|
|
256
|
-
if (node.type !== 1 /* ELEMENT */ ||
|
|
257
|
-
node.tagType !== 0 /* ELEMENT */) {
|
|
260
|
+
if (node.type !== 1 /* NodeTypes.ELEMENT */ ||
|
|
261
|
+
node.tagType !== 0 /* ElementTypes.ELEMENT */) {
|
|
258
262
|
return;
|
|
259
263
|
}
|
|
260
264
|
return function ssrPostTransformElement() {
|
|
@@ -267,7 +271,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
267
271
|
// overwrite other static attrs and can affect final rendering result,
|
|
268
272
|
// so when they are present we need to bail out to full `renderAttrs`
|
|
269
273
|
const hasDynamicVBind = compilerDom.hasDynamicKeyVBind(node);
|
|
270
|
-
const hasCustomDir = node.props.some(p => p.type === 7 /* DIRECTIVE */ && !shared.isBuiltInDirective(p.name));
|
|
274
|
+
const hasCustomDir = node.props.some(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && !shared.isBuiltInDirective(p.name));
|
|
271
275
|
const needMergeProps = hasDynamicVBind || hasCustomDir;
|
|
272
276
|
if (needMergeProps) {
|
|
273
277
|
const { props, directives } = compilerDom.buildProps(node, context, node.props, false /* isComponent */, false /* isDynamicComponent */, true /* ssr */);
|
|
@@ -278,7 +282,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
278
282
|
const existingText = node.children[0];
|
|
279
283
|
// If interpolation, this is dynamic <textarea> content, potentially
|
|
280
284
|
// injected by v-model and takes higher priority than v-bind value
|
|
281
|
-
if (!existingText || existingText.type !== 5 /* INTERPOLATION */) {
|
|
285
|
+
if (!existingText || existingText.type !== 5 /* NodeTypes.INTERPOLATION */) {
|
|
282
286
|
// <textarea> with dynamic v-bind. We don't know if the final props
|
|
283
287
|
// will contain .value, so we will have to do something special:
|
|
284
288
|
// assign the merged props to a temp variable, and check whether
|
|
@@ -334,7 +338,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
334
338
|
continue;
|
|
335
339
|
}
|
|
336
340
|
// special cases with children override
|
|
337
|
-
if (prop.type === 7 /* DIRECTIVE */) {
|
|
341
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
338
342
|
if (prop.name === 'html' && prop.exp) {
|
|
339
343
|
rawChildrenMap.set(node, prop.exp);
|
|
340
344
|
}
|
|
@@ -342,7 +346,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
342
346
|
node.children = [compilerDom.createInterpolation(prop.exp, prop.loc)];
|
|
343
347
|
}
|
|
344
348
|
else if (prop.name === 'slot') {
|
|
345
|
-
context.onError(compilerDom.createCompilerError(40 /* X_V_SLOT_MISPLACED */, prop.loc));
|
|
349
|
+
context.onError(compilerDom.createCompilerError(40 /* ErrorCodes.X_V_SLOT_MISPLACED */, prop.loc));
|
|
346
350
|
}
|
|
347
351
|
else if (isTextareaWithValue(node, prop) && prop.exp) {
|
|
348
352
|
if (!needMergeProps) {
|
|
@@ -392,7 +396,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
392
396
|
]));
|
|
393
397
|
}
|
|
394
398
|
else {
|
|
395
|
-
context.onError(createSSRCompilerError(61 /* X_SSR_UNSAFE_ATTR_NAME */, key.loc));
|
|
399
|
+
context.onError(createSSRCompilerError(61 /* SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME */, key.loc));
|
|
396
400
|
}
|
|
397
401
|
}
|
|
398
402
|
}
|
|
@@ -442,7 +446,7 @@ const ssrTransformElement = (node, context) => {
|
|
|
442
446
|
function buildSSRProps(props, directives, context) {
|
|
443
447
|
let mergePropsArgs = [];
|
|
444
448
|
if (props) {
|
|
445
|
-
if (props.type === 14 /* JS_CALL_EXPRESSION */) {
|
|
449
|
+
if (props.type === 14 /* NodeTypes.JS_CALL_EXPRESSION */) {
|
|
446
450
|
// already a mergeProps call
|
|
447
451
|
mergePropsArgs = props.arguments;
|
|
448
452
|
}
|
|
@@ -463,7 +467,7 @@ function buildSSRProps(props, directives, context) {
|
|
|
463
467
|
: mergePropsArgs[0];
|
|
464
468
|
}
|
|
465
469
|
function isTrueFalseValue(prop) {
|
|
466
|
-
if (prop.type === 7 /* DIRECTIVE */) {
|
|
470
|
+
if (prop.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
467
471
|
return (prop.name === 'bind' &&
|
|
468
472
|
prop.arg &&
|
|
469
473
|
compilerDom.isStaticExp(prop.arg) &&
|
|
@@ -480,7 +484,7 @@ function isTextareaWithValue(node, prop) {
|
|
|
480
484
|
}
|
|
481
485
|
function mergeCall(call, arg) {
|
|
482
486
|
const existing = call.arguments[0];
|
|
483
|
-
if (existing.type === 17 /* JS_ARRAY_EXPRESSION */) {
|
|
487
|
+
if (existing.type === 17 /* NodeTypes.JS_ARRAY_EXPRESSION */) {
|
|
484
488
|
existing.elements.push(arg);
|
|
485
489
|
}
|
|
486
490
|
else {
|
|
@@ -495,7 +499,7 @@ function removeStaticBinding(tag, binding) {
|
|
|
495
499
|
}
|
|
496
500
|
}
|
|
497
501
|
function findVModel(node) {
|
|
498
|
-
return node.props.find(p => p.type === 7 /* DIRECTIVE */ && p.name === 'model' && p.exp);
|
|
502
|
+
return node.props.find(p => p.type === 7 /* NodeTypes.DIRECTIVE */ && p.name === 'model' && p.exp);
|
|
499
503
|
}
|
|
500
504
|
function ssrProcessElement(node, context) {
|
|
501
505
|
const isVoidTag = context.options.isVoidTag || shared.NO;
|
|
@@ -548,7 +552,7 @@ function ssrProcessTransitionGroup(node, context) {
|
|
|
548
552
|
const entry = wipMap$1.get(node);
|
|
549
553
|
if (entry) {
|
|
550
554
|
const { tag, propsExp } = entry;
|
|
551
|
-
if (tag.type === 7 /* DIRECTIVE */) {
|
|
555
|
+
if (tag.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
552
556
|
// dynamic :tag
|
|
553
557
|
context.pushStringPart(`<`);
|
|
554
558
|
context.pushStringPart(tag.exp);
|
|
@@ -599,8 +603,8 @@ const componentTypeMap = new WeakMap();
|
|
|
599
603
|
// In phase 2. we convert the WIP slots from phase 1 into ssr-specific codegen
|
|
600
604
|
// nodes.
|
|
601
605
|
const ssrTransformComponent = (node, context) => {
|
|
602
|
-
if (node.type !== 1 /* ELEMENT */ ||
|
|
603
|
-
node.tagType !== 1 /* COMPONENT */) {
|
|
606
|
+
if (node.type !== 1 /* NodeTypes.ELEMENT */ ||
|
|
607
|
+
node.tagType !== 1 /* ElementTypes.COMPONENT */) {
|
|
604
608
|
return;
|
|
605
609
|
}
|
|
606
610
|
const component = compilerDom.resolveComponentType(node, context, true /* ssr */);
|
|
@@ -704,7 +708,7 @@ function ssrProcessComponent(node, context, parent) {
|
|
|
704
708
|
}
|
|
705
709
|
// #5351: filter out comment children inside transition
|
|
706
710
|
if (component === compilerDom.TRANSITION) {
|
|
707
|
-
node.children = node.children.filter(c => c.type !== 3 /* COMMENT */);
|
|
711
|
+
node.children = node.children.filter(c => c.type !== 3 /* NodeTypes.COMMENT */);
|
|
708
712
|
}
|
|
709
713
|
processChildren(node, context);
|
|
710
714
|
}
|
|
@@ -759,16 +763,16 @@ function createVNodeSlotBranch(props, children, parentContext) {
|
|
|
759
763
|
};
|
|
760
764
|
// wrap the children with a wrapper template for proper children treatment.
|
|
761
765
|
const wrapperNode = {
|
|
762
|
-
type: 1 /* ELEMENT */,
|
|
763
|
-
ns: 0 /* HTML */,
|
|
766
|
+
type: 1 /* NodeTypes.ELEMENT */,
|
|
767
|
+
ns: 0 /* Namespaces.HTML */,
|
|
764
768
|
tag: 'template',
|
|
765
|
-
tagType: 3 /* TEMPLATE */,
|
|
769
|
+
tagType: 3 /* ElementTypes.TEMPLATE */,
|
|
766
770
|
isSelfClosing: false,
|
|
767
771
|
// important: provide v-slot="props" on the wrapper for proper
|
|
768
772
|
// scope analysis
|
|
769
773
|
props: [
|
|
770
774
|
{
|
|
771
|
-
type: 7 /* DIRECTIVE */,
|
|
775
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
772
776
|
name: 'slot',
|
|
773
777
|
exp: props,
|
|
774
778
|
arg: undefined,
|
|
@@ -843,8 +847,10 @@ function ssrCodegenTransform(ast, options) {
|
|
|
843
847
|
// we do this instead of inlining the expression to ensure the vars are
|
|
844
848
|
// only resolved once per render
|
|
845
849
|
if (options.ssrCssVars) {
|
|
846
|
-
const
|
|
850
|
+
const cssContext = compilerDom.createTransformContext(compilerDom.createRoot([]), options);
|
|
851
|
+
const varsExp = compilerDom.processExpression(compilerDom.createSimpleExpression(options.ssrCssVars, false), cssContext);
|
|
847
852
|
context.body.push(compilerDom.createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`]));
|
|
853
|
+
Array.from(cssContext.helpers.keys()).forEach(helper => ast.helpers.push(helper));
|
|
848
854
|
}
|
|
849
855
|
const isFragment = ast.children.length > 1 && ast.children.some(c => !compilerDom.isText(c));
|
|
850
856
|
processChildren(ast, context, isFragment);
|
|
@@ -906,54 +912,54 @@ function processChildren(parent, context, asFragment = false, disableNestedFragm
|
|
|
906
912
|
for (let i = 0; i < children.length; i++) {
|
|
907
913
|
const child = children[i];
|
|
908
914
|
switch (child.type) {
|
|
909
|
-
case 1 /* ELEMENT */:
|
|
915
|
+
case 1 /* NodeTypes.ELEMENT */:
|
|
910
916
|
switch (child.tagType) {
|
|
911
|
-
case 0 /* ELEMENT */:
|
|
917
|
+
case 0 /* ElementTypes.ELEMENT */:
|
|
912
918
|
ssrProcessElement(child, context);
|
|
913
919
|
break;
|
|
914
|
-
case 1 /* COMPONENT */:
|
|
920
|
+
case 1 /* ElementTypes.COMPONENT */:
|
|
915
921
|
ssrProcessComponent(child, context, parent);
|
|
916
922
|
break;
|
|
917
|
-
case 2 /* SLOT */:
|
|
923
|
+
case 2 /* ElementTypes.SLOT */:
|
|
918
924
|
ssrProcessSlotOutlet(child, context);
|
|
919
925
|
break;
|
|
920
|
-
case 3 /* TEMPLATE */:
|
|
926
|
+
case 3 /* ElementTypes.TEMPLATE */:
|
|
921
927
|
// TODO
|
|
922
928
|
break;
|
|
923
929
|
default:
|
|
924
|
-
context.onError(createSSRCompilerError(63 /* X_SSR_INVALID_AST_NODE */, child.loc));
|
|
930
|
+
context.onError(createSSRCompilerError(63 /* SSRErrorCodes.X_SSR_INVALID_AST_NODE */, child.loc));
|
|
925
931
|
// make sure we exhaust all possible types
|
|
926
932
|
const exhaustiveCheck = child;
|
|
927
933
|
return exhaustiveCheck;
|
|
928
934
|
}
|
|
929
935
|
break;
|
|
930
|
-
case 2 /* TEXT */:
|
|
936
|
+
case 2 /* NodeTypes.TEXT */:
|
|
931
937
|
context.pushStringPart(shared.escapeHtml(child.content));
|
|
932
938
|
break;
|
|
933
|
-
case 3 /* COMMENT */:
|
|
939
|
+
case 3 /* NodeTypes.COMMENT */:
|
|
934
940
|
// no need to escape comment here because the AST can only
|
|
935
941
|
// contain valid comments.
|
|
936
942
|
context.pushStringPart(`<!--${child.content}-->`);
|
|
937
943
|
break;
|
|
938
|
-
case 5 /* INTERPOLATION */:
|
|
944
|
+
case 5 /* NodeTypes.INTERPOLATION */:
|
|
939
945
|
context.pushStringPart(compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [child.content]));
|
|
940
946
|
break;
|
|
941
|
-
case 9 /* IF */:
|
|
947
|
+
case 9 /* NodeTypes.IF */:
|
|
942
948
|
ssrProcessIf(child, context, disableNestedFragments);
|
|
943
949
|
break;
|
|
944
|
-
case 11 /* FOR */:
|
|
950
|
+
case 11 /* NodeTypes.FOR */:
|
|
945
951
|
ssrProcessFor(child, context, disableNestedFragments);
|
|
946
952
|
break;
|
|
947
|
-
case 10 /* IF_BRANCH */:
|
|
953
|
+
case 10 /* NodeTypes.IF_BRANCH */:
|
|
948
954
|
// no-op - handled by ssrProcessIf
|
|
949
955
|
break;
|
|
950
|
-
case 12 /* TEXT_CALL */:
|
|
951
|
-
case 8 /* COMPOUND_EXPRESSION */:
|
|
956
|
+
case 12 /* NodeTypes.TEXT_CALL */:
|
|
957
|
+
case 8 /* NodeTypes.COMPOUND_EXPRESSION */:
|
|
952
958
|
// no-op - these two types can never appear as template child node since
|
|
953
959
|
// `transformText` is not used during SSR compile.
|
|
954
960
|
break;
|
|
955
961
|
default:
|
|
956
|
-
context.onError(createSSRCompilerError(63 /* X_SSR_INVALID_AST_NODE */, child.loc));
|
|
962
|
+
context.onError(createSSRCompilerError(63 /* SSRErrorCodes.X_SSR_INVALID_AST_NODE */, child.loc));
|
|
957
963
|
// make sure we exhaust all possible types
|
|
958
964
|
const exhaustiveCheck = child;
|
|
959
965
|
return exhaustiveCheck;
|
|
@@ -974,10 +980,10 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
974
980
|
function checkDuplicatedValue() {
|
|
975
981
|
const value = compilerDom.findProp(node, 'value');
|
|
976
982
|
if (value) {
|
|
977
|
-
context.onError(compilerDom.createDOMCompilerError(57 /* X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
983
|
+
context.onError(compilerDom.createDOMCompilerError(57 /* DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE */, value.loc));
|
|
978
984
|
}
|
|
979
985
|
}
|
|
980
|
-
if (node.tagType === 0 /* ELEMENT */) {
|
|
986
|
+
if (node.tagType === 0 /* ElementTypes.ELEMENT */) {
|
|
981
987
|
const res = { props: [] };
|
|
982
988
|
const defaultProps = [
|
|
983
989
|
// default value binding for text type inputs
|
|
@@ -987,7 +993,7 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
987
993
|
const type = compilerDom.findProp(node, 'type');
|
|
988
994
|
if (type) {
|
|
989
995
|
const value = findValueBinding(node);
|
|
990
|
-
if (type.type === 7 /* DIRECTIVE */) {
|
|
996
|
+
if (type.type === 7 /* NodeTypes.DIRECTIVE */) {
|
|
991
997
|
// dynamic type
|
|
992
998
|
res.ssrTagParts = [
|
|
993
999
|
compilerDom.createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
|
|
@@ -1011,7 +1017,7 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
1011
1017
|
case 'checkbox':
|
|
1012
1018
|
const trueValueBinding = compilerDom.findProp(node, 'true-value');
|
|
1013
1019
|
if (trueValueBinding) {
|
|
1014
|
-
const trueValue = trueValueBinding.type === 6 /* ATTRIBUTE */
|
|
1020
|
+
const trueValue = trueValueBinding.type === 6 /* NodeTypes.ATTRIBUTE */
|
|
1015
1021
|
? JSON.stringify(trueValueBinding.value.content)
|
|
1016
1022
|
: trueValueBinding.exp;
|
|
1017
1023
|
res.props = [
|
|
@@ -1031,7 +1037,7 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
1031
1037
|
}
|
|
1032
1038
|
break;
|
|
1033
1039
|
case 'file':
|
|
1034
|
-
context.onError(compilerDom.createDOMCompilerError(56 /* X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
1040
|
+
context.onError(compilerDom.createDOMCompilerError(56 /* DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT */, dir.loc));
|
|
1035
1041
|
break;
|
|
1036
1042
|
default:
|
|
1037
1043
|
checkDuplicatedValue();
|
|
@@ -1053,7 +1059,7 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
1053
1059
|
}
|
|
1054
1060
|
else if (node.tag === 'select') ;
|
|
1055
1061
|
else {
|
|
1056
|
-
context.onError(compilerDom.createDOMCompilerError(54 /* X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
1062
|
+
context.onError(compilerDom.createDOMCompilerError(54 /* DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT */, dir.loc));
|
|
1057
1063
|
}
|
|
1058
1064
|
return res;
|
|
1059
1065
|
}
|
|
@@ -1065,7 +1071,7 @@ const ssrTransformModel = (dir, node, context) => {
|
|
|
1065
1071
|
function findValueBinding(node) {
|
|
1066
1072
|
const valueBinding = compilerDom.findProp(node, 'value');
|
|
1067
1073
|
return valueBinding
|
|
1068
|
-
? valueBinding.type === 7 /* DIRECTIVE */
|
|
1074
|
+
? valueBinding.type === 7 /* NodeTypes.DIRECTIVE */
|
|
1069
1075
|
? valueBinding.exp
|
|
1070
1076
|
: compilerDom.createSimpleExpression(valueBinding.value.content, true)
|
|
1071
1077
|
: compilerDom.createSimpleExpression(`null`, false);
|
|
@@ -1073,7 +1079,7 @@ function findValueBinding(node) {
|
|
|
1073
1079
|
|
|
1074
1080
|
const ssrTransformShow = (dir, node, context) => {
|
|
1075
1081
|
if (!dir.exp) {
|
|
1076
|
-
context.onError(compilerDom.createDOMCompilerError(58 /* X_V_SHOW_NO_EXPRESSION */));
|
|
1082
|
+
context.onError(compilerDom.createDOMCompilerError(58 /* DOMErrorCodes.X_V_SHOW_NO_EXPRESSION */));
|
|
1077
1083
|
}
|
|
1078
1084
|
return {
|
|
1079
1085
|
props: [
|
|
@@ -1084,17 +1090,17 @@ const ssrTransformShow = (dir, node, context) => {
|
|
|
1084
1090
|
};
|
|
1085
1091
|
};
|
|
1086
1092
|
|
|
1087
|
-
const filterChild = (node) => node.children.filter(n => n.type !== 3 /* COMMENT */);
|
|
1093
|
+
const filterChild = (node) => node.children.filter(n => n.type !== 3 /* NodeTypes.COMMENT */);
|
|
1088
1094
|
const hasSingleChild = (node) => filterChild(node).length === 1;
|
|
1089
1095
|
const ssrInjectFallthroughAttrs = (node, context) => {
|
|
1090
1096
|
// _attrs is provided as a function argument.
|
|
1091
1097
|
// mark it as a known identifier so that it doesn't get prefixed by
|
|
1092
1098
|
// transformExpression.
|
|
1093
|
-
if (node.type === 0 /* ROOT */) {
|
|
1099
|
+
if (node.type === 0 /* NodeTypes.ROOT */) {
|
|
1094
1100
|
context.identifiers._attrs = 1;
|
|
1095
1101
|
}
|
|
1096
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
1097
|
-
node.tagType === 1 /* COMPONENT */ &&
|
|
1102
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1103
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */ &&
|
|
1098
1104
|
(compilerDom.isBuiltInType(node.tag, 'Transition') ||
|
|
1099
1105
|
compilerDom.isBuiltInType(node.tag, 'KeepAlive'))) {
|
|
1100
1106
|
const rootChildren = filterChild(context.root);
|
|
@@ -1106,15 +1112,15 @@ const ssrInjectFallthroughAttrs = (node, context) => {
|
|
|
1106
1112
|
}
|
|
1107
1113
|
}
|
|
1108
1114
|
const parent = context.parent;
|
|
1109
|
-
if (!parent || parent.type !== 0 /* ROOT */) {
|
|
1115
|
+
if (!parent || parent.type !== 0 /* NodeTypes.ROOT */) {
|
|
1110
1116
|
return;
|
|
1111
1117
|
}
|
|
1112
|
-
if (node.type === 10 /* IF_BRANCH */ && hasSingleChild(node)) {
|
|
1118
|
+
if (node.type === 10 /* NodeTypes.IF_BRANCH */ && hasSingleChild(node)) {
|
|
1113
1119
|
// detect cases where the parent v-if is not the only root level node
|
|
1114
1120
|
let hasEncounteredIf = false;
|
|
1115
1121
|
for (const c of filterChild(parent)) {
|
|
1116
|
-
if (c.type === 9 /* IF */ ||
|
|
1117
|
-
(c.type === 1 /* ELEMENT */ && compilerDom.findDir(c, 'if'))) {
|
|
1122
|
+
if (c.type === 9 /* NodeTypes.IF */ ||
|
|
1123
|
+
(c.type === 1 /* NodeTypes.ELEMENT */ && compilerDom.findDir(c, 'if'))) {
|
|
1118
1124
|
// multiple root v-if
|
|
1119
1125
|
if (hasEncounteredIf)
|
|
1120
1126
|
return;
|
|
@@ -1124,7 +1130,7 @@ const ssrInjectFallthroughAttrs = (node, context) => {
|
|
|
1124
1130
|
// node before v-if
|
|
1125
1131
|
!hasEncounteredIf ||
|
|
1126
1132
|
// non else nodes
|
|
1127
|
-
!(c.type === 1 /* ELEMENT */ && compilerDom.findDir(c, /else/, true))) {
|
|
1133
|
+
!(c.type === 1 /* NodeTypes.ELEMENT */ && compilerDom.findDir(c, /else/, true))) {
|
|
1128
1134
|
return;
|
|
1129
1135
|
}
|
|
1130
1136
|
}
|
|
@@ -1135,12 +1141,12 @@ const ssrInjectFallthroughAttrs = (node, context) => {
|
|
|
1135
1141
|
}
|
|
1136
1142
|
};
|
|
1137
1143
|
function injectFallthroughAttrs(node) {
|
|
1138
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
1139
|
-
(node.tagType === 0 /* ELEMENT */ ||
|
|
1140
|
-
node.tagType === 1 /* COMPONENT */) &&
|
|
1144
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1145
|
+
(node.tagType === 0 /* ElementTypes.ELEMENT */ ||
|
|
1146
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */) &&
|
|
1141
1147
|
!compilerDom.findDir(node, 'for')) {
|
|
1142
1148
|
node.props.push({
|
|
1143
|
-
type: 7 /* DIRECTIVE */,
|
|
1149
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
1144
1150
|
name: 'bind',
|
|
1145
1151
|
arg: undefined,
|
|
1146
1152
|
exp: compilerDom.createSimpleExpression(`_attrs`, false),
|
|
@@ -1157,14 +1163,14 @@ const ssrInjectCssVars = (node, context) => {
|
|
|
1157
1163
|
// _cssVars is initialized once per render function
|
|
1158
1164
|
// the code is injected in ssrCodegenTransform when creating the
|
|
1159
1165
|
// ssr transform context
|
|
1160
|
-
if (node.type === 0 /* ROOT */) {
|
|
1166
|
+
if (node.type === 0 /* NodeTypes.ROOT */) {
|
|
1161
1167
|
context.identifiers._cssVars = 1;
|
|
1162
1168
|
}
|
|
1163
1169
|
const parent = context.parent;
|
|
1164
|
-
if (!parent || parent.type !== 0 /* ROOT */) {
|
|
1170
|
+
if (!parent || parent.type !== 0 /* NodeTypes.ROOT */) {
|
|
1165
1171
|
return;
|
|
1166
1172
|
}
|
|
1167
|
-
if (node.type === 10 /* IF_BRANCH */) {
|
|
1173
|
+
if (node.type === 10 /* NodeTypes.IF_BRANCH */) {
|
|
1168
1174
|
for (const child of node.children) {
|
|
1169
1175
|
injectCssVars(child);
|
|
1170
1176
|
}
|
|
@@ -1174,14 +1180,14 @@ const ssrInjectCssVars = (node, context) => {
|
|
|
1174
1180
|
}
|
|
1175
1181
|
};
|
|
1176
1182
|
function injectCssVars(node) {
|
|
1177
|
-
if (node.type === 1 /* ELEMENT */ &&
|
|
1178
|
-
(node.tagType === 0 /* ELEMENT */ ||
|
|
1179
|
-
node.tagType === 1 /* COMPONENT */) &&
|
|
1183
|
+
if (node.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1184
|
+
(node.tagType === 0 /* ElementTypes.ELEMENT */ ||
|
|
1185
|
+
node.tagType === 1 /* ElementTypes.COMPONENT */) &&
|
|
1180
1186
|
!compilerDom.findDir(node, 'for')) {
|
|
1181
1187
|
if (compilerDom.isBuiltInType(node.tag, 'Suspense')) {
|
|
1182
1188
|
for (const child of node.children) {
|
|
1183
|
-
if (child.type === 1 /* ELEMENT */ &&
|
|
1184
|
-
child.tagType === 3 /* TEMPLATE */) {
|
|
1189
|
+
if (child.type === 1 /* NodeTypes.ELEMENT */ &&
|
|
1190
|
+
child.tagType === 3 /* ElementTypes.TEMPLATE */) {
|
|
1185
1191
|
// suspense slot
|
|
1186
1192
|
child.children.forEach(injectCssVars);
|
|
1187
1193
|
}
|
|
@@ -1192,7 +1198,7 @@ function injectCssVars(node) {
|
|
|
1192
1198
|
}
|
|
1193
1199
|
else {
|
|
1194
1200
|
node.props.push({
|
|
1195
|
-
type: 7 /* DIRECTIVE */,
|
|
1201
|
+
type: 7 /* NodeTypes.DIRECTIVE */,
|
|
1196
1202
|
name: 'bind',
|
|
1197
1203
|
arg: undefined,
|
|
1198
1204
|
exp: compilerDom.createSimpleExpression(`_cssVars`, false),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-ssr",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.39",
|
|
4
4
|
"description": "@vue/compiler-ssr",
|
|
5
5
|
"main": "dist/compiler-ssr.cjs.js",
|
|
6
6
|
"types": "dist/compiler-ssr.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-ssr#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@vue/shared": "3.2.
|
|
32
|
-
"@vue/compiler-dom": "3.2.
|
|
31
|
+
"@vue/shared": "3.2.39",
|
|
32
|
+
"@vue/compiler-dom": "3.2.39"
|
|
33
33
|
}
|
|
34
34
|
}
|