@@ -66,55 +66,54 @@ export class RenderContext {
66
66
}
67
67
68
68
next ( ) {
69
- const lastState = this . renderStates [ this . renderStates . length - 1 ]
70
- if ( isUndef ( lastState ) ) {
71
- return this . done ( )
72
- }
73
- /* eslint-disable no-case-declarations */
74
- switch ( lastState . type ) {
75
- case 'Element' :
76
- case 'Fragment' :
77
- const { children, total } = lastState
78
- const rendered = lastState . rendered ++
79
- if ( rendered < total ) {
80
- this . renderNode ( children [ rendered ] , false , this )
81
- } else {
69
+ // eslint-disable-next-line
70
+ while ( true ) {
71
+ const lastState = this . renderStates [ this . renderStates . length - 1 ]
72
+ if ( isUndef ( lastState ) ) {
73
+ return this . done ( )
74
+ }
75
+ /* eslint-disable no-case-declarations */
76
+ switch ( lastState . type ) {
77
+ case 'Element' :
78
+ case 'Fragment' :
79
+ const { children, total } = lastState
80
+ const rendered = lastState . rendered ++
81
+ if ( rendered < total ) {
82
+ return this . renderNode ( children [ rendered ] , false , this )
83
+ } else {
84
+ this . renderStates . pop ( )
85
+ if ( lastState . type === 'Element' ) {
86
+ return this . write ( lastState . endTag , this . next )
87
+ }
88
+ }
89
+ break
90
+ case 'Component' :
82
91
this . renderStates . pop ( )
83
- if ( lastState . type === 'Element' ) {
84
- this . write ( lastState . endTag , this . next )
92
+ this . activeInstance = lastState . prevActive
93
+ break
94
+ case 'ComponentWithCache' :
95
+ this . renderStates . pop ( )
96
+ const { buffer, bufferIndex, componentBuffer, key } = lastState
97
+ const result = {
98
+ html : buffer [ bufferIndex ] ,
99
+ components : componentBuffer [ bufferIndex ]
100
+ }
101
+ this . cache . set ( key , result )
102
+ if ( bufferIndex === 0 ) {
103
+ // this is a top-level cached component,
104
+ // exit caching mode.
105
+ this . write . caching = false
85
106
} else {
86
- this . next ( )
107
+ // parent component is also being cached,
108
+ // merge self into parent's result
109
+ buffer [ bufferIndex - 1 ] += result . html
110
+ const prev = componentBuffer [ bufferIndex - 1 ]
111
+ result . components . forEach ( c => prev . add ( c ) )
87
112
}
88
- }
89
- break
90
- case 'Component' :
91
- this . renderStates . pop ( )
92
- this . activeInstance = lastState . prevActive
93
- this . next ( )
94
- break
95
- case 'ComponentWithCache' :
96
- this . renderStates . pop ( )
97
- const { buffer, bufferIndex, componentBuffer, key } = lastState
98
- const result = {
99
- html : buffer [ bufferIndex ] ,
100
- components : componentBuffer [ bufferIndex ]
101
- }
102
- this . cache . set ( key , result )
103
- if ( bufferIndex === 0 ) {
104
- // this is a top-level cached component,
105
- // exit caching mode.
106
- this . write . caching = false
107
- } else {
108
- // parent component is also being cached,
109
- // merge self into parent's result
110
- buffer [ bufferIndex - 1 ] += result . html
111
- const prev = componentBuffer [ bufferIndex - 1 ]
112
- result . components . forEach ( c => prev . add ( c ) )
113
- }
114
- buffer . length = bufferIndex
115
- componentBuffer . length = bufferIndex
116
- this . next ( )
117
- break
113
+ buffer . length = bufferIndex
114
+ componentBuffer . length = bufferIndex
115
+ break
116
+ }
118
117
}
119
118
}
120
119
}
0 commit comments