Skip to content

Commit 9d32a3c

Browse files
committed
refactor: use isTeleport/isKeepAlive utils in stubs
1 parent 4c81246 commit 9d32a3c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/vnodeTransformers/stubComponentsTransformer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { VTUVNodeTypeTransformer } from './util'
1+
import { isKeepAlive, isTeleport, VTUVNodeTypeTransformer } from './util'
22
import {
33
Transition,
44
TransitionGroup,
@@ -115,7 +115,7 @@ export function createStubComponentsTransformer({
115115
}: CreateStubComponentsTransformerConfig): VTUVNodeTypeTransformer {
116116
return function componentsTransformer(type, instance) {
117117
// stub teleport by default via config.global.stubs
118-
if ((type as any) === Teleport && 'teleport' in stubs) {
118+
if (isTeleport(type) && 'teleport' in stubs) {
119119
if (stubs.teleport === false) return type
120120

121121
return createStub({
@@ -126,7 +126,7 @@ export function createStubComponentsTransformer({
126126
}
127127

128128
// stub keep-alive/KeepAlive by default via config.global.stubs
129-
if ((type as any) === KeepAlive && ('keep-alive' in stubs || 'KeepAlive' in stubs)) {
129+
if (isKeepAlive(type) && ('keep-alive' in stubs || 'KeepAlive' in stubs)) {
130130
if ('keep-alive' in stubs && stubs['keep-alive'] === false) return type
131131
if ('KeepAlive' in stubs && stubs['KeepAlive'] === false) return type
132132

src/vnodeTransformers/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export type VTUVNodeTypeTransformer = (
2020
instance: InstanceArgsType
2121
) => VNodeTransformerInputComponentType
2222

23-
const isTeleport = (type: any): boolean => type.__isTeleport
24-
const isKeepAlive = (type: any): boolean => type.__isKeepAlive
23+
export const isTeleport = (type: any): boolean => type.__isTeleport
24+
export const isKeepAlive = (type: any): boolean => type.__isKeepAlive
2525

2626
export const createVNodeTransformer = ({
2727
transformers

0 commit comments

Comments
 (0)