Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion flow/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ declare type ComponentOptions = {
_propKeys?: Array<string>;
_parentVnode?: VNode;
_parentListeners?: ?Object;
_renderChildren?: ?VNodeChildren
_renderChildren?: ?VNodeChildren;
_componentTag: ?string;
_scopeId: ?string;
}

declare type PropOptions = {
Expand Down
21 changes: 21 additions & 0 deletions flow/ssr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare type ComponentWithCacheContext = {
type: 'ComponentWithCache';
bufferIndex: number;
buffer: Array<string>;
key: string;
}

declare type ElementContext = {
type: 'Element';
children: Array<VNode>;
rendered: number;
endTag: string;
total: number;
}

declare type ComponentContext = {
type: 'Component';
prevActive: Component;
}

declare type RenderState = ComponentContext | ComponentWithCacheContext | ElementContext
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"eslint-loader": "^1.3.0",
"eslint-plugin-flowtype": "^2.16.0",
"eslint-plugin-html": "^1.5.2",
"flow-bin": "^0.32.0",
"flow-bin": "^0.33.0",
"he": "^1.1.0",
"http-server": "^0.9.0",
"jasmine": "2.4.x",
Expand Down
16 changes: 7 additions & 9 deletions src/compiler/codegen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ function genElement (el: ASTElement): string {
// component or element
let code
if (el.component) {
code = genComponent(el)
code = genComponent(el.component, el)
} else {
const data = genData(el)
const data = el.plain ? undefined : genData(el)

const children = el.inlineTemplate ? null : genChildren(el)
code = `_h('${el.tag}'${
data ? `,${data}` : '' // data
Expand Down Expand Up @@ -95,11 +96,7 @@ function genFor (el: any): string {
'})'
}

function genData (el: ASTElement): string | void {
if (el.plain) {
return
}

function genData (el: ASTElement): string {
let data = '{'

// directives first.
Expand Down Expand Up @@ -229,9 +226,10 @@ function genSlot (el: ASTElement): string {
: `_t(${slotName})`
}

function genComponent (el: any): string {
// componentName is el.component, take it as argument to shun flow's pessimistic refinement
function genComponent (componentName, el): string {
const children = el.inlineTemplate ? null : genChildren(el)
return `_h(${el.component},${genData(el)}${
return `_h(${componentName},${genData(el)}${
children ? `,${children}` : ''
})`
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function assertProp (
*/
function assertType (value: any, type: Function): {
valid: boolean,
expectedType: string
expectedType: ?string
} {
let valid
let expectedType = getType(type)
Expand Down
4 changes: 1 addition & 3 deletions src/server/render-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import { createWriteFunction } from './write'

export default class RenderStream extends stream.Readable {
buffer: string;
render: Function;
render: (write: Function, done: Function) => void;
expectedSize: number;
stackDepth: number;
write: Function;
next: Function;
end: Function;
Expand All @@ -26,7 +25,6 @@ export default class RenderStream extends stream.Readable {
this.buffer = ''
this.render = render
this.expectedSize = 0
this.stackDepth = 0

this.write = createWriteFunction((text, next) => {
const n = this.expectedSize
Expand Down
Loading