@vue/compiler-ssr 3.6.0-rc.14 → 3.6.0-rc.15

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-ssr v3.6.0-rc.14
2
+ * @vue/compiler-ssr v3.6.0-rc.15
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -79,8 +79,11 @@ function processIfBranch(branch, context, disableNestedFragments = false, index
79
79
  childContext.pushStringPart(`<!--]-->`);
80
80
  return (0, _vue_compiler_dom.createBlockStatement)(childContext.body);
81
81
  }
82
- const { children } = branch;
83
- return processChildrenAsStatement(branch, context, !disableNestedFragments && (children.length !== 1 || children[0].type !== 1) && !(children.length === 1 && children[0].type === 11));
82
+ return processChildrenAsStatement(branch, context, !disableNestedFragments && !isBareBranch(branch));
83
+ }
84
+ /** Whether a branch renders as it is: its sole element or v-for, unwrapped. */
85
+ function isBareBranch({ children }) {
86
+ return children.length === 1 && (children[0].type === 1 || children[0].type === 11);
84
87
  }
85
88
  /**
86
89
  * Whether two branches of a chain could start with the same node. Branches
@@ -181,6 +184,9 @@ function ssrProcessSuspense(node, context) {
181
184
  //#endregion
182
185
  //#region packages/compiler-ssr/src/transforms/ssrTransformElement.ts
183
186
  const rawChildrenMap = /* @__PURE__ */ new WeakMap();
187
+ const ssrTransformStyle = (node, context) => {
188
+ if (node.type === 1 && node.tagType !== 0) (0, _vue_compiler_dom.transformStyle)(node, context);
189
+ };
184
190
  const ssrTransformElement = (node, context) => {
185
191
  if (node.type !== 1 || node.tagType !== 0) return;
186
192
  return function ssrPostTransformElement() {
@@ -196,6 +202,7 @@ const ssrTransformElement = (node, context) => {
196
202
  }
197
203
  const needMergeProps = hasDynamicVBind || hasCustomDir;
198
204
  if (needMergeProps) {
205
+ (0, _vue_compiler_dom.transformStyle)(node, context);
199
206
  const { props, directives } = (0, _vue_compiler_dom.buildProps)(node, context, node.props, false, false, true);
200
207
  if (props || directives.length) {
201
208
  const mergedProps = buildSSRProps(props, directives, context);
@@ -228,6 +235,8 @@ const ssrTransformElement = (node, context) => {
228
235
  let dynamicClassBinding = void 0;
229
236
  let staticClassBinding = void 0;
230
237
  let dynamicStyleBinding = void 0;
238
+ let staticStyleBinding = void 0;
239
+ let staticStyleIndex = -1;
231
240
  for (let i = 0; i < node.props.length; i++) {
232
241
  const prop = node.props[i];
233
242
  if (node.tag === "input" && isTrueFalseValue(prop)) continue;
@@ -254,7 +263,16 @@ const ssrTransformElement = (node, context) => {
254
263
  if (attrName === "class") openTag.push(` class="`, dynamicClassBinding = (0, _vue_compiler_dom.createCallExpression)(context.helper(SSR_RENDER_CLASS), [value]), `"`);
255
264
  else if (attrName === "style") {
256
265
  if (dynamicStyleBinding) mergeCall(dynamicStyleBinding, value);
257
- else openTag.push(` style="`, dynamicStyleBinding = (0, _vue_compiler_dom.createCallExpression)(context.helper(SSR_RENDER_STYLE), [value]), `"`);
266
+ else {
267
+ dynamicStyleBinding = (0, _vue_compiler_dom.createCallExpression)(context.helper(SSR_RENDER_STYLE), [staticStyleBinding ? (0, _vue_compiler_dom.createArrayExpression)([staticStyleBinding, value]) : value]);
268
+ const parts = [
269
+ ` style="`,
270
+ dynamicStyleBinding,
271
+ `"`
272
+ ];
273
+ if (staticStyleBinding) openTag.splice(staticStyleIndex, 1, ...parts);
274
+ else openTag.push(...parts);
275
+ }
258
276
  } else {
259
277
  attrName = node.tag.indexOf("-") > 0 ? attrName : _vue_shared.propsToAttrMap[attrName] || attrName.toLowerCase();
260
278
  if ((0, _vue_shared.isBooleanAttr)(attrName)) openTag.push((0, _vue_compiler_dom.createConditionalExpression)((0, _vue_compiler_dom.createCallExpression)(context.helper(SSR_INCLUDE_BOOLEAN_ATTR), [value]), (0, _vue_compiler_dom.createSimpleExpression)(" " + attrName, true), (0, _vue_compiler_dom.createSimpleExpression)("", true), false));
@@ -276,6 +294,16 @@ const ssrTransformElement = (node, context) => {
276
294
  else if (!needMergeProps) {
277
295
  if (name === "key" || name === "ref") continue;
278
296
  if (name === "class" && prop.value) staticClassBinding = JSON.stringify(prop.value.content);
297
+ if (name === "style" && prop.value) {
298
+ const style = (0, _vue_shared.parseStringStyle)(prop.value.content);
299
+ if (dynamicStyleBinding) mergeCall(dynamicStyleBinding, JSON.stringify(style));
300
+ else {
301
+ staticStyleBinding = JSON.stringify(style);
302
+ staticStyleIndex = openTag.length;
303
+ openTag.push(` style="${(0, _vue_shared.escapeHtml)((0, _vue_shared.stringifyStyle)(style))}"`);
304
+ }
305
+ continue;
306
+ }
279
307
  openTag.push(` ${prop.name}` + (prop.value ? `="${(0, _vue_shared.escapeHtml)(prop.value.content)}"` : ``));
280
308
  }
281
309
  }
@@ -481,6 +509,16 @@ const ssrTransformComponent = (node, context) => {
481
509
  ]);
482
510
  };
483
511
  };
512
+ /**
513
+ * Whether the server render of `node` begins with markup of its own: a
514
+ * Teleport opens with its markers, a TransitionGroup with its tag or range,
515
+ * a Suspense in a vapor component with its slot's range, an appearing
516
+ * Transition with its `<template>`.
517
+ */
518
+ function beginsWithOwnMarkup(node) {
519
+ const component = componentTypeMap.get(node);
520
+ return component === _vue_compiler_dom.TELEPORT || component === _vue_compiler_dom.TRANSITION_GROUP || component === _vue_compiler_dom.SUSPENSE || component === _vue_compiler_dom.TRANSITION && !!(0, _vue_compiler_dom.findProp)(node, "appear", false, true);
521
+ }
484
522
  function ssrProcessComponent(node, context, parent) {
485
523
  const component = componentTypeMap.get(node);
486
524
  if (!node.ssrCodegenNode) {
@@ -632,7 +670,11 @@ function ssrCodegenTransform(ast, options) {
632
670
  ast.helpers.add(helper);
633
671
  });
634
672
  }
635
- processChildren(ast, context, ast.children.length > 1 && ast.children.some((c) => !(0, _vue_compiler_dom.isText)(c)));
673
+ const isFragment = ast.children.length > 1 && ast.children.some((c) => !(0, _vue_compiler_dom.isText)(c));
674
+ const vaporRange = !!options.vapor && (isFragment || opensRange(ast.children[0]));
675
+ if (vaporRange) context.pushStringPart(`<!--{-->`);
676
+ processChildren(ast, context, isFragment && !options.vapor);
677
+ if (vaporRange) context.pushStringPart(`<!--}-->`);
636
678
  ast.codegenNode = (0, _vue_compiler_dom.createBlockStatement)(context.body);
637
679
  ast.ssrHelpers = Array.from(/* @__PURE__ */ new Set([...Array.from(ast.helpers).filter((h) => h in ssrHelpers), ...context.helpers]));
638
680
  ast.helpers = new Set(Array.from(ast.helpers).filter((h) => !(h in ssrHelpers)));
@@ -671,6 +713,16 @@ function createSSRTransformContext(root, options, helpers = /* @__PURE__ */ new
671
713
  }
672
714
  };
673
715
  }
716
+ /** Whether the server render of `node` may begin with a component's range. */
717
+ function opensRange(node) {
718
+ if (!node) return false;
719
+ if (node.type === 1) return node.tagType === 1 && !beginsWithOwnMarkup(node);
720
+ if (node.type === 9) {
721
+ const [branch] = node.branches;
722
+ return node.branches.length === 1 && isBareBranch(branch) && opensRange(branch.children[0]);
723
+ }
724
+ return false;
725
+ }
674
726
  function createChildContext(parent, withSlotScopeId = parent.withSlotScopeId) {
675
727
  return createSSRTransformContext(parent.root, parent.options, parent.helpers, withSlotScopeId);
676
728
  }
@@ -883,7 +935,7 @@ function compile(source, options = {}) {
883
935
  ssrTransformElement,
884
936
  ssrTransformComponent,
885
937
  _vue_compiler_dom.trackSlotScopes,
886
- _vue_compiler_dom.transformStyle,
938
+ ssrTransformStyle,
887
939
  ...options.nodeTransforms || []
888
940
  ],
889
941
  directiveTransforms: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-ssr",
3
- "version": "3.6.0-rc.14",
3
+ "version": "3.6.0-rc.15",
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.6.0-rc.14",
32
- "@vue/compiler-dom": "3.6.0-rc.14"
31
+ "@vue/shared": "3.6.0-rc.15",
32
+ "@vue/compiler-dom": "3.6.0-rc.15"
33
33
  }
34
34
  }