Przeglądaj źródła

support scopeId

Evan You 9 lat temu
rodzic
commit
55d8bfd6fd

+ 3 - 0
flow/compiler.js

@@ -16,6 +16,9 @@ declare type CompilerOptions = {
   shouldDecodeTags?: boolean;
   shouldDecodeNewlines?: boolean;
 
+  // for ssr optimization compiler
+  scopeId?: string;
+
   // runtime user-configurable
   delimiters?: [string, string]; // template delimiters
 };

+ 4 - 1
src/server/optimizing-compiler/codegen.js

@@ -189,7 +189,10 @@ function elementToOpenTagSegments (el, state): Array<StringSegment> {
       )
     )
   }
-  // console.log(segments)
+  // _scopedId
+  if (state.options.scopeId) {
+    segments.push({ type: RAW, value: ` ${state.options.scopeId}` })
+  }
   segments.push({ type: RAW, value: `>` })
   return segments
 }

+ 4 - 2
src/server/render.js

@@ -18,10 +18,12 @@ const warnOnce = msg => {
 }
 
 const normalizeRender = vm => {
-  const { render, template } = vm.$options
+  const { render, template, _scopeId } = vm.$options
   if (isUndef(render)) {
     if (template) {
-      Object.assign(vm.$options, ssrCompileToFunctions(template))
+      Object.assign(vm.$options, ssrCompileToFunctions(template, {
+        scopeId: _scopeId
+      }))
     } else {
       throw new Error(
         `render function or template not defined in component: ${