@@ -24,6 +24,9 @@ export const isTeleport = (type: any): boolean => type.__isTeleport
24
24
export const isTeleportDisabled = ( props : VNode [ 'props' ] ) : boolean =>
25
25
props && ( props . disabled || props . disabled === '' )
26
26
27
+ const isTargetSVG = ( target : RendererElement ) : boolean =>
28
+ typeof SVGElement !== 'undefined' && target instanceof SVGElement
29
+
27
30
const resolveTarget = < T = RendererElement > (
28
31
props : TeleportProps | null ,
29
32
select : RendererOptions [ 'querySelector' ]
@@ -80,6 +83,7 @@ export const TeleportImpl = {
80
83
81
84
const disabled = isTeleportDisabled ( n2 . props )
82
85
const { shapeFlag, children } = n2
86
+
83
87
if ( n1 == null ) {
84
88
// insert anchors in the main view
85
89
const placeholder = ( n2 . el = __DEV__
@@ -90,11 +94,12 @@ export const TeleportImpl = {
90
94
: createText ( '' ) )
91
95
insert ( placeholder , container , anchor )
92
96
insert ( mainAnchor , container , anchor )
93
-
94
97
const target = ( n2 . target = resolveTarget ( n2 . props , querySelector ) )
95
98
const targetAnchor = ( n2 . targetAnchor = createText ( '' ) )
96
99
if ( target ) {
97
100
insert ( targetAnchor , target )
101
+ // #2652 we could be teleporting from a non-SVG tree into an SVG tree
102
+ isSVG = isSVG || isTargetSVG ( target )
98
103
} else if ( __DEV__ && ! disabled ) {
99
104
warn ( 'Invalid Teleport target on mount:' , target , `(${ typeof target } )` )
100
105
}
@@ -129,6 +134,7 @@ export const TeleportImpl = {
129
134
const wasDisabled = isTeleportDisabled ( n1 . props )
130
135
const currentContainer = wasDisabled ? container : target
131
136
const currentAnchor = wasDisabled ? mainAnchor : targetAnchor
137
+ isSVG = isSVG || isTargetSVG ( target )
132
138
133
139
if ( n2 . dynamicChildren ) {
134
140
// fast path when the teleport happens to be a block root
0 commit comments