polish(teleport): do not warn missing target when teleport is disabled (#2021)

This commit is contained in:
HcySunYang
2020-09-02 09:05:51 +08:00
committed by GitHub
parent 0d0970f9cd
commit 93b8ff94a4
2 changed files with 33 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ import { warn } from '../warning'
export type TeleportVNode = VNode<RendererNode, RendererElement, TeleportProps>
export interface TeleportProps {
to: string | RendererElement
to: string | RendererElement | null | undefined
disabled?: boolean
}
@@ -50,7 +50,7 @@ const resolveTarget = <T = RendererElement>(
return target as any
}
} else {
if (__DEV__ && !targetSelector) {
if (__DEV__ && !targetSelector && !isTeleportDisabled(props)) {
warn(`Invalid Teleport target: ${targetSelector}`)
}
return targetSelector as any
@@ -94,7 +94,7 @@ export const TeleportImpl = {
const targetAnchor = (n2.targetAnchor = createText(''))
if (target) {
insert(targetAnchor, target)
} else if (__DEV__) {
} else if (__DEV__ && !disabled) {
warn('Invalid Teleport target on mount:', target, `(${typeof target})`)
}