Przeglądaj źródła

small tweak to ssr

Evan You 10 lat temu
rodzic
commit
a9ee5c9db4

+ 1 - 1
package.json

@@ -13,7 +13,7 @@
     "dev": "webpack --watch --config build/webpack.dist.dev.config.js",
     "dev:test": "karma start build/karma.dev.config.js",
     "dev:ssr": "webpack --watch --config build/webpack.ssr.dev.config.js",
-    "test": "npm run lint && npm run test:unit && npm run test:e2e",
+    "test": "npm run lint && npm run test:unit && npm run test:e2e && npm run test:ssr",
     "build": "NODE_ENV=production node build/build.js",
     "lint": "eslint src build test",
     "test:unit": "karma start build/karma.unit.config.js",

+ 3 - 2
src/server/create-streaming-renderer.js

@@ -22,10 +22,11 @@ export function createStreamingRenderer (modules, directives, isUnaryTag) {
 
   function renderElement (el, write, next) {
     const startTag = renderStartingTag(el, modules, directives)
+    const endTag = `</${el.tag}>`
     if (isUnaryTag(el.tag)) {
       write(startTag, next)
     } else if (!el.children || !el.children.length) {
-      write(startTag + `</${el.tag}>`, next)
+      write(startTag + endTag, next)
     } else {
       write(startTag, () => {
         const total = el.children.length
@@ -37,7 +38,7 @@ export function createStreamingRenderer (modules, directives, isUnaryTag) {
             if (rendered < total) {
               renderChild(el.children[rendered])
             } else {
-              write(`</${el.tag}>`, next)
+              write(endTag, next)
             }
           })
         }

+ 2 - 2
src/server/render-stream.js

@@ -7,8 +7,8 @@ import stream from 'stream'
  */
 
 export default class RenderStream extends stream.Readable {
-  constructor (render, options) {
-    super(options)
+  constructor (render) {
+    super()
     this.buffer = ''
     this.render = render
     this.maxStackDepth = 500