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 = {
57
57
_propKeys ?: Array < string > ;
58
58
_parentVnode ?: VNode ;
59
59
_parentListeners ?: ?Object ;
60
- _renderChildren ?: ?VNodeChildren
60
+ _renderChildren ?: ?VNodeChildren ;
61
+ _componentTag : ?string ;
62
+ _scopeId : ?string ;
61
63
}
62
64
63
65
declare 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 67
67
"eslint-loader" : " ^1.3.0" ,
68
68
"eslint-plugin-flowtype" : " ^2.16.0" ,
69
69
"eslint-plugin-vue" : " ^1.0.0" ,
70
- "flow-bin" : " ^0.32 .0" ,
70
+ "flow-bin" : " ^0.33 .0" ,
71
71
"he" : " ^1.1.0" ,
72
72
"http-server" : " ^0.9.0" ,
73
73
"jasmine" : " 2.4.x" ,
Original file line number Diff line number Diff line change @@ -53,9 +53,10 @@ function genElement (el: ASTElement): string {
53
53
// component or element
54
54
let code
55
55
if ( el . component ) {
56
- code = genComponent ( el )
56
+ code = genComponent ( el . component , el )
57
57
} else {
58
- const data = genData ( el )
58
+ const data = el . plain ? undefined : genData ( el )
59
+
59
60
const children = el . inlineTemplate ? null : genChildren ( el )
60
61
code = `_h('${ el . tag } '${
61
62
data ? `,${ data } ` : '' // data
@@ -95,11 +96,7 @@ function genFor (el: any): string {
95
96
'})'
96
97
}
97
98
98
- function genData ( el : ASTElement ) : string | void {
99
- if ( el . plain ) {
100
- return
101
- }
102
-
99
+ function genData ( el : ASTElement ) : string {
103
100
let data = '{'
104
101
105
102
// directives first.
@@ -229,9 +226,10 @@ function genSlot (el: ASTElement): string {
229
226
: `_t(${ slotName } )`
230
227
}
231
228
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 {
233
231
const children = el . inlineTemplate ? null : genChildren ( el )
234
- return `_h(${ el . component } ,${ genData ( el ) } ${
232
+ return `_h(${ componentName } ,${ genData ( el ) } ${
235
233
children ? `,${ children } ` : ''
236
234
} )`
237
235
}
Original file line number Diff line number Diff line change @@ -126,7 +126,7 @@ function assertProp (
126
126
*/
127
127
function assertType ( value : any , type : Function ) : {
128
128
valid: boolean ,
129
- expectedType : string
129
+ expectedType : ? string
130
130
} {
131
131
let valid
132
132
let expectedType = getType ( type )
Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ import { createWriteFunction } from './write'
13
13
14
14
export default class RenderStream extends stream . Readable {
15
15
buffer : string ;
16
- render : Function ;
16
+ render : ( write : Function , done : Function ) => void ;
17
17
expectedSize : number ;
18
- stackDepth : number ;
19
18
write : Function ;
20
19
next : Function ;
21
20
end : Function ;
@@ -26,7 +25,6 @@ export default class RenderStream extends stream.Readable {
26
25
this . buffer = ''
27
26
this . render = render
28
27
this . expectedSize = 0
29
- this . stackDepth = 0
30
28
31
29
this . write = createWriteFunction ( ( text , next ) => {
32
30
const n = this . expectedSize
You can’t perform that action at this time.
0 commit comments