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,29 +271,7 @@ export function createRenderer(options: RendererOptions) {
const doMount = () => { const doMount = () => {
handle.runner = autorun( handle.runner = autorun(
() => { () => {
if (handle.prevTree) { if (!handle.prevTree) {
// mounted
const { prevTree, current } = handle
if (__DEV__) {
pushWarningContext(current)
}
const nextTree = (handle.prevTree = current.children = renderFunctionalRoot(
current
))
queuePostCommitHook(() => {
current.el = nextTree.el
})
patch(
prevTree as MountedVNode,
nextTree,
platformParentNode(current.el),
current as MountedVNode,
isSVG
)
if (__DEV__) {
popWarningContext()
}
} else {
// initial mount // initial mount
if (__DEV__) { if (__DEV__) {
pushWarningContext(vnode) pushWarningContext(vnode)
@ -308,6 +286,8 @@ export function createRenderer(options: RendererOptions) {
if (__DEV__) { if (__DEV__) {
popWarningContext() popWarningContext()
} }
} else {
updateFunctionalComponent(handle, isSVG)
} }
}, },
{ {
@ -324,6 +304,30 @@ export function createRenderer(options: RendererOptions) {
} }
} }
function updateFunctionalComponent(handle: FunctionalHandle, isSVG: boolean) {
// mounted
const { prevTree, current } = handle
if (__DEV__) {
pushWarningContext(current)
}
const nextTree = (handle.prevTree = current.children = renderFunctionalRoot(
current
))
queuePostCommitHook(() => {
current.el = nextTree.el
})
patch(
prevTree as MountedVNode,
nextTree,
platformParentNode(current.el),
current as MountedVNode,
isSVG
)
if (__DEV__) {
popWarningContext()
}
}
function mountText( function mountText(
vnode: VNode, vnode: VNode,
container: RenderNode | null, container: RenderNode | null,

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,9 +127,11 @@ function flush(): void {
} else { } else {
break break
} }
const now = getNow() if (!__COMPAT__) {
if (now - start > frameBudget && job.expiration > now) { const now = getNow()
break if (now - start > frameBudget && job.expiration > now) {
break
}
} }
} }
@ -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()
} }
} }