diff --git a/flow/options.js b/flow/options.js index 60f6298045d..19db33b3bad 100644 --- a/flow/options.js +++ b/flow/options.js @@ -57,7 +57,8 @@ declare type ComponentOptions = { _propKeys?: Array; _parentVnode?: VNode; _parentListeners?: ?Object; - _renderChildren?: ?VNodeChildren + _renderChildren?: ?VNodeChildren; + _componentTag: ?string; } declare type PropOptions = { diff --git a/package.json b/package.json index 794bcaa4b03..3238eebe8c2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/compiler/codegen/index.js b/src/compiler/codegen/index.js index fb8f9ef6ac0..d2572007d41 100644 --- a/src/compiler/codegen/index.js +++ b/src/compiler/codegen/index.js @@ -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 @@ -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. @@ -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}` : '' })` } diff --git a/src/core/util/props.js b/src/core/util/props.js index 5358ce2d1ab..bebd5cf8f62 100644 --- a/src/core/util/props.js +++ b/src/core/util/props.js @@ -126,7 +126,7 @@ function assertProp ( */ function assertType (value: any, type: Function): { valid: boolean, - expectedType: string + expectedType: ?string } { let valid let expectedType = getType(type)