refactor(runtime-core): remove the need for currentSuspense
This commit is contained in:
parent
54a11c7bec
commit
573bcb2e11
@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
PublicAPIComponent,
|
PublicAPIComponent,
|
||||||
Component,
|
Component,
|
||||||
currentSuspense,
|
|
||||||
currentInstance,
|
currentInstance,
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
isInSSRComponentSetup
|
isInSSRComponentSetup
|
||||||
@ -118,7 +117,7 @@ export function defineAsyncComponent<
|
|||||||
|
|
||||||
// suspense-controlled or SSR.
|
// suspense-controlled or SSR.
|
||||||
if (
|
if (
|
||||||
(__FEATURE_SUSPENSE__ && suspensible && currentSuspense) ||
|
(__FEATURE_SUSPENSE__ && suspensible && instance.suspense) ||
|
||||||
(__NODE_JS__ && isInSSRComponentSetup)
|
(__NODE_JS__ && isInSSRComponentSetup)
|
||||||
) {
|
) {
|
||||||
return load()
|
return load()
|
||||||
|
@ -20,7 +20,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
currentInstance,
|
currentInstance,
|
||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
currentSuspense,
|
|
||||||
Data,
|
Data,
|
||||||
isInSSRComponentSetup,
|
isInSSRComponentSetup,
|
||||||
recordInstanceBoundEffect
|
recordInstanceBoundEffect
|
||||||
@ -139,7 +138,6 @@ function doWatch(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const instance = currentInstance
|
const instance = currentInstance
|
||||||
const suspense = currentSuspense
|
|
||||||
|
|
||||||
let getter: () => any
|
let getter: () => any
|
||||||
if (isArray(source)) {
|
if (isArray(source)) {
|
||||||
@ -238,9 +236,7 @@ function doWatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scheduler = job => {
|
scheduler = job => queuePostRenderEffect(job, instance && instance.suspense)
|
||||||
queuePostRenderEffect(job, suspense)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const runner = effect(getter, {
|
const runner = effect(getter, {
|
||||||
|
@ -145,6 +145,7 @@ export interface ComponentInternalInstance {
|
|||||||
emit: Emit
|
emit: Emit
|
||||||
|
|
||||||
// suspense related
|
// suspense related
|
||||||
|
suspense: SuspenseBoundary | null
|
||||||
asyncDep: Promise<any> | null
|
asyncDep: Promise<any> | null
|
||||||
asyncResolved: boolean
|
asyncResolved: boolean
|
||||||
|
|
||||||
@ -177,7 +178,8 @@ const emptyAppContext = createAppContext()
|
|||||||
|
|
||||||
export function createComponentInstance(
|
export function createComponentInstance(
|
||||||
vnode: VNode,
|
vnode: VNode,
|
||||||
parent: ComponentInternalInstance | null
|
parent: ComponentInternalInstance | null,
|
||||||
|
suspense: SuspenseBoundary | null
|
||||||
) {
|
) {
|
||||||
// inherit parent app context - or - if root, adopt from root vnode
|
// inherit parent app context - or - if root, adopt from root vnode
|
||||||
const appContext =
|
const appContext =
|
||||||
@ -213,7 +215,8 @@ export function createComponentInstance(
|
|||||||
components: Object.create(appContext.components),
|
components: Object.create(appContext.components),
|
||||||
directives: Object.create(appContext.directives),
|
directives: Object.create(appContext.directives),
|
||||||
|
|
||||||
// async dependency management
|
// suspense related
|
||||||
|
suspense,
|
||||||
asyncDep: null,
|
asyncDep: null,
|
||||||
asyncResolved: false,
|
asyncResolved: false,
|
||||||
|
|
||||||
@ -266,7 +269,6 @@ export function createComponentInstance(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export let currentInstance: ComponentInternalInstance | null = null
|
export let currentInstance: ComponentInternalInstance | null = null
|
||||||
export let currentSuspense: SuspenseBoundary | null = null
|
|
||||||
|
|
||||||
export const getCurrentInstance: () => ComponentInternalInstance | null = () =>
|
export const getCurrentInstance: () => ComponentInternalInstance | null = () =>
|
||||||
currentInstance || currentRenderingInstance
|
currentInstance || currentRenderingInstance
|
||||||
@ -351,7 +353,6 @@ function setupStatefulComponent(
|
|||||||
setup.length > 1 ? createSetupContext(instance) : null)
|
setup.length > 1 ? createSetupContext(instance) : null)
|
||||||
|
|
||||||
currentInstance = instance
|
currentInstance = instance
|
||||||
currentSuspense = parentSuspense
|
|
||||||
pauseTracking()
|
pauseTracking()
|
||||||
const setupResult = callWithErrorHandling(
|
const setupResult = callWithErrorHandling(
|
||||||
setup,
|
setup,
|
||||||
@ -361,7 +362,6 @@ function setupStatefulComponent(
|
|||||||
)
|
)
|
||||||
resetTracking()
|
resetTracking()
|
||||||
currentInstance = null
|
currentInstance = null
|
||||||
currentSuspense = null
|
|
||||||
|
|
||||||
if (isPromise(setupResult)) {
|
if (isPromise(setupResult)) {
|
||||||
if (isSSR) {
|
if (isSSR) {
|
||||||
@ -478,10 +478,8 @@ function finishComponentSetup(
|
|||||||
// support for 2.x options
|
// support for 2.x options
|
||||||
if (__FEATURE_OPTIONS__) {
|
if (__FEATURE_OPTIONS__) {
|
||||||
currentInstance = instance
|
currentInstance = instance
|
||||||
currentSuspense = parentSuspense
|
|
||||||
applyOptions(instance, Component)
|
applyOptions(instance, Component)
|
||||||
currentInstance = null
|
currentInstance = null
|
||||||
currentSuspense = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,7 +1028,8 @@ function baseCreateRenderer(
|
|||||||
) => {
|
) => {
|
||||||
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
|
const instance: ComponentInternalInstance = (initialVNode.component = createComponentInstance(
|
||||||
initialVNode,
|
initialVNode,
|
||||||
parentComponent
|
parentComponent,
|
||||||
|
parentSuspense
|
||||||
))
|
))
|
||||||
|
|
||||||
if (__HMR__ && instance.type.__hmrId) {
|
if (__HMR__ && instance.type.__hmrId) {
|
||||||
|
@ -144,7 +144,7 @@ function renderComponentVNode(
|
|||||||
vnode: VNode,
|
vnode: VNode,
|
||||||
parentComponent: ComponentInternalInstance | null = null
|
parentComponent: ComponentInternalInstance | null = null
|
||||||
): ResolvedSSRBuffer | Promise<ResolvedSSRBuffer> {
|
): ResolvedSSRBuffer | Promise<ResolvedSSRBuffer> {
|
||||||
const instance = createComponentInstance(vnode, parentComponent)
|
const instance = createComponentInstance(vnode, parentComponent, null)
|
||||||
const res = setupComponent(
|
const res = setupComponent(
|
||||||
instance,
|
instance,
|
||||||
null /* parentSuspense (no need to track for SSR) */,
|
null /* parentSuspense (no need to track for SSR) */,
|
||||||
|
Loading…
Reference in New Issue
Block a user