Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commite4b1b57

Browse files
committed
fix(ssr): adjust call stack size defer threshold
fixvuejs#8545
1 parent19c33a7 commite4b1b57

File tree

2 files changed

+46
-47
lines changed

2 files changed

+46
-47
lines changed

‎src/server/render-context.js‎

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -66,55 +66,54 @@ export class RenderContext {
6666
}
6767

6868
next(){
69-
constlastState=this.renderStates[this.renderStates.length-1]
70-
if(isUndef(lastState)){
71-
returnthis.done()
72-
}
73-
/* eslint-disable no-case-declarations */
74-
switch(lastState.type){
75-
case'Element':
76-
case'Fragment':
77-
const{ children, total}=lastState
78-
constrendered=lastState.rendered++
79-
if(rendered<total){
80-
this.renderNode(children[rendered],false,this)
81-
}else{
69+
// eslint-disable-next-line
70+
while(true){
71+
constlastState=this.renderStates[this.renderStates.length-1]
72+
if(isUndef(lastState)){
73+
returnthis.done()
74+
}
75+
/* eslint-disable no-case-declarations */
76+
switch(lastState.type){
77+
case'Element':
78+
case'Fragment':
79+
const{ children, total}=lastState
80+
constrendered=lastState.rendered++
81+
if(rendered<total){
82+
returnthis.renderNode(children[rendered],false,this)
83+
}else{
84+
this.renderStates.pop()
85+
if(lastState.type==='Element'){
86+
returnthis.write(lastState.endTag,this.next)
87+
}
88+
}
89+
break
90+
case'Component':
8291
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+
constresult={
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
85106
}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+
constprev=componentBuffer[bufferIndex-1]
111+
result.components.forEach(c=>prev.add(c))
87112
}
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-
constresult={
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-
constprev=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+
}
118117
}
119118
}
120119
}

‎src/server/write.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*@flow */
22

3-
constMAX_STACK_DEPTH=1000
3+
constMAX_STACK_DEPTH=900
44
constnoop=_=>_
55

66
constdefer=typeofprocess!=='undefined'&&process.nextTick

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp