wip: disable time-slicing in compat mode

This commit is contained in:
Evan You 2018-11-08 18:41:04 -05:00
parent 132da6c354
commit d39eb6cdbc
2 changed files with 36 additions and 28 deletions

View File

@ -271,7 +271,40 @@ export function createRenderer(options: RendererOptions) {
const doMount = () => { const doMount = () => {
handle.runner = autorun( handle.runner = autorun(
() => { () => {
if (handle.prevTree) { if (!handle.prevTree) {
// initial mount
if (__DEV__) {
pushWarningContext(vnode)
}
const subTree = (handle.prevTree = vnode.children = renderFunctionalRoot(
vnode
))
queuePostCommitHook(() => {
vnode.el = subTree.el as RenderNode
})
mount(subTree, container, vnode as MountedVNode, isSVG, endNode)
if (__DEV__) {
popWarningContext()
}
} else {
updateFunctionalComponent(handle, isSVG)
}
},
{
scheduler: queueUpdate
}
)
}
// we are using vnode.ref to store the functional component's update job
if (__COMPAT__) {
doMount()
} else {
queueJob(doMount)
}
}
function updateFunctionalComponent(handle: FunctionalHandle, isSVG: boolean) {
// mounted // mounted
const { prevTree, current } = handle const { prevTree, current } = handle
if (__DEV__) { if (__DEV__) {
@ -293,35 +326,6 @@ export function createRenderer(options: RendererOptions) {
if (__DEV__) { if (__DEV__) {
popWarningContext() popWarningContext()
} }
} else {
// initial mount
if (__DEV__) {
pushWarningContext(vnode)
}
const subTree = (handle.prevTree = vnode.children = renderFunctionalRoot(
vnode
))
queuePostCommitHook(() => {
vnode.el = subTree.el as RenderNode
})
mount(subTree, container, vnode as MountedVNode, isSVG, endNode)
if (__DEV__) {
popWarningContext()
}
}
},
{
scheduler: queueUpdate
}
)
}
// we are using vnode.ref to store the functional component's update job
if (__COMPAT__) {
doMount()
} else {
queueJob(doMount)
}
} }
function mountText( function mountText(

View File

@ -32,7 +32,7 @@ function flushAfterMicroTask() {
} }
// Macrotask for time slicing // Macrotask for time slicing
const key = `__vueSchedulerTick` const key = `$vueTick`
window.addEventListener( window.addEventListener(
'message', 'message',
@ -127,11 +127,13 @@ function flush(): void {
} else { } else {
break break
} }
if (!__COMPAT__) {
const now = getNow() const now = getNow()
if (now - start > frameBudget && job.expiration > now) { if (now - start > frameBudget && job.expiration > now) {
break break
} }
} }
}
if (patchQueue.length === 0) { if (patchQueue.length === 0) {
// all done, time to commit! // all done, time to commit!
@ -147,7 +149,7 @@ function flush(): void {
} }
// some post commit hook triggered more updates... // some post commit hook triggered more updates...
if (patchQueue.length > 0) { if (patchQueue.length > 0) {
if (getNow() - start > frameBudget) { if (!__COMPAT__ && getNow() - start > frameBudget) {
return flushAfterMacroTask() return flushAfterMacroTask()
} else { } else {
// not out of budget yet, flush sync // not out of budget yet, flush sync
@ -162,6 +164,8 @@ function flush(): void {
} }
} else { } else {
// got more job to do // got more job to do
// shouldn't reach here in compat mode, because the patchQueue is
// guarunteed to be drained
flushAfterMacroTask() flushAfterMacroTask()
} }
} }