@vue/compiler-ssr 3.0.7 → 3.0.11

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.
@@ -104,14 +104,20 @@ function ssrProcessFor(node, context, disableNestedFragments = false) {
104
104
  const ssrTransformSlotOutlet = (node, context) => {
105
105
  if (compilerDom.isSlotOutlet(node)) {
106
106
  const { slotName, slotProps } = compilerDom.processSlotOutlet(node, context);
107
- node.ssrCodegenNode = compilerDom.createCallExpression(context.helper(SSR_RENDER_SLOT), [
107
+ const args = [
108
108
  `_ctx.$slots`,
109
109
  slotName,
110
110
  slotProps || `{}`,
111
+ // fallback content placeholder. will be replaced in the process phase
111
112
  `null`,
112
113
  `_push`,
113
114
  `_parent`
114
- ]);
115
+ ];
116
+ // inject slot scope id if current template uses :slotted
117
+ if (context.scopeId && context.slotted !== false) {
118
+ args.push(`"${context.scopeId}-s"`);
119
+ }
120
+ node.ssrCodegenNode = compilerDom.createCallExpression(context.helper(SSR_RENDER_SLOT), args);
115
121
  }
116
122
  };
117
123
  function ssrProcessSlotOutlet(node, context) {
@@ -123,6 +129,13 @@ function ssrProcessSlotOutlet(node, context) {
123
129
  // _renderSlot(slots, name, props, fallback, ...)
124
130
  renderCall.arguments[3] = fallbackRenderFn;
125
131
  }
132
+ // Forwarded <slot/>. Merge slot scope ids
133
+ if (context.withSlotScopeId) {
134
+ const slotScopeId = renderCall.arguments[6];
135
+ renderCall.arguments[6] = slotScopeId
136
+ ? `${slotScopeId} + _scopeId`
137
+ : `_scopeId`;
138
+ }
126
139
  context.pushStatement(node.ssrCodegenNode);
127
140
  }
128
141
 
@@ -365,6 +378,10 @@ function ssrProcessComponent(node, context) {
365
378
  // is called by `_ssrRenderSlot`.
366
379
  fn.body = compilerDom.createIfStatement(compilerDom.createSimpleExpression(`_push`, false), processChildrenAsStatement(children, context, false, true /* withSlotScopeId */), vnodeBranch);
367
380
  }
381
+ // component is inside a slot, inherit slot scope Id
382
+ if (context.withSlotScopeId) {
383
+ node.ssrCodegenNode.arguments.push(`_scopeId`);
384
+ }
368
385
  if (typeof component === 'string') {
369
386
  // static component
370
387
  context.pushStatement(compilerDom.createCallExpression(`_push`, [node.ssrCodegenNode]));
@@ -433,11 +450,23 @@ function subTransform(node, options, parentContext) {
433
450
  // inherit parent scope analysis state
434
451
  childContext.scopes = { ...parentContext.scopes };
435
452
  childContext.identifiers = { ...parentContext.identifiers };
453
+ childContext.imports = parentContext.imports;
436
454
  // traverse
437
455
  compilerDom.traverseNode(childRoot, childContext);
438
456
  ['helpers', 'components', 'directives'].forEach(key => {
439
- childContext[key].forEach((value) => {
440
- parentContext[key].add(value);
457
+ childContext[key].forEach((value, helperKey) => {
458
+ if (key === 'helpers') {
459
+ const parentCount = parentContext.helpers.get(helperKey);
460
+ if (parentCount === undefined) {
461
+ parentContext.helpers.set(helperKey, value);
462
+ }
463
+ else {
464
+ parentContext.helpers.set(helperKey, value + parentCount);
465
+ }
466
+ }
467
+ else {
468
+ parentContext[key].add(value);
469
+ }
441
470
  });
442
471
  });
443
472
  // imports/hoists are not merged because:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-ssr",
3
- "version": "3.0.7",
3
+ "version": "3.0.11",
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/vue-next/tree/master/packages/compiler-ssr#readme",
30
30
  "dependencies": {
31
- "@vue/shared": "3.0.7",
32
- "@vue/compiler-dom": "3.0.7"
31
+ "@vue/shared": "3.0.11",
32
+ "@vue/compiler-dom": "3.0.11"
33
33
  }
34
34
  }