File tree Expand file tree Collapse file tree 9 files changed +245
-171
lines changed Expand file tree Collapse file tree 9 files changed +245
-171
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,9 @@ declare type ComponentOptions = {
5757 _propKeys ?: Array < string > ;
5858 _parentVnode ?: VNode ;
5959 _parentListeners ?: ?Object ;
60- _renderChildren ?: ?VNodeChildren
60+ _renderChildren ?: ?VNodeChildren ;
61+ _componentTag : ?string ;
62+ _scopeId : ?string ;
6163}
6264
6365declare type PropOptions = {
Original file line number Diff line number Diff line change 1+ declare type ComponentWithCacheContext = {
2+ type : 'ComponentWithCache' ;
3+ bufferIndex: number ;
4+ buffer: Array < string > ;
5+ key: string ;
6+ }
7+
8+ declare type ElementContext = {
9+ type : 'Element' ;
10+ children: Array < VNode > ;
11+ rendered: number ;
12+ endTag: string ;
13+ total: number ;
14+ }
15+
16+ declare type ComponentContext = {
17+ type : 'Component' ;
18+ prevActive: Component ;
19+ }
20+
21+ declare type RenderState = ComponentContext | ComponentWithCacheContext | ElementContext
Original file line number Diff line number Diff line change 6767 "eslint-loader" : " ^1.3.0" ,
6868 "eslint-plugin-flowtype" : " ^2.16.0" ,
6969 "eslint-plugin-vue" : " ^1.0.0" ,
70- "flow-bin" : " ^0.32 .0" ,
70+ "flow-bin" : " ^0.33 .0" ,
7171 "he" : " ^1.1.0" ,
7272 "http-server" : " ^0.9.0" ,
7373 "jasmine" : " 2.4.x" ,
Original file line number Diff line number Diff line change @@ -53,9 +53,10 @@ function genElement (el: ASTElement): string {
5353 // component or element
5454 let code
5555 if ( el . component ) {
56- code = genComponent ( el )
56+ code = genComponent ( el . component , el )
5757 } else {
58- const data = genData ( el )
58+ const data = el . plain ? undefined : genData ( el )
59+
5960 const children = el . inlineTemplate ? null : genChildren ( el )
6061 code = `_h('${ el . tag } '${
6162 data ? `,${ data } ` : '' // data
@@ -95,11 +96,7 @@ function genFor (el: any): string {
9596 '})'
9697}
9798
98- function genData ( el : ASTElement ) : string | void {
99- if ( el . plain ) {
100- return
101- }
102-
99+ function genData ( el : ASTElement ) : string {
103100 let data = '{'
104101
105102 // directives first.
@@ -229,9 +226,10 @@ function genSlot (el: ASTElement): string {
229226 : `_t(${ slotName } )`
230227}
231228
232- function genComponent ( el : any ) : string {
229+ // componentName is el.component, take it as argument to shun flow's pessimistic refinement
230+ function genComponent ( componentName , el ) : string {
233231 const children = el . inlineTemplate ? null : genChildren ( el )
234- return `_h(${ el . component } ,${ genData ( el ) } ${
232+ return `_h(${ componentName } ,${ genData ( el ) } ${
235233 children ? `,${ children } ` : ''
236234 } )`
237235}
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ function assertProp (
126126 */
127127function assertType ( value : any , type : Function ) : {
128128 valid: boolean ,
129- expectedType : string
129+ expectedType : ? string
130130} {
131131 let valid
132132 let expectedType = getType ( type )
Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ import { createWriteFunction } from './write'
1313
1414export default class RenderStream extends stream . Readable {
1515 buffer : string ;
16- render : Function ;
16+ render : ( write : Function , done : Function ) => void ;
1717 expectedSize : number ;
18- stackDepth : number ;
1918 write : Function ;
2019 next : Function ;
2120 end : Function ;
@@ -26,7 +25,6 @@ export default class RenderStream extends stream.Readable {
2625 this . buffer = ''
2726 this . render = render
2827 this . expectedSize = 0
29- this . stackDepth = 0
3028
3129 this . write = createWriteFunction ( ( text , next ) => {
3230 const n = this . expectedSize
You can’t perform that action at this time.
0 commit comments