@vue/compiler-ssr 3.2.37 → 3.2.38

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