@@ -139,59 +139,59 @@ export class TeleportFragment extends VaporFragment {
139139 insert ( ( this . nodes = children ) , this . mountContainer ! , this . mountAnchor ! )
140140 }
141141
142- private handlePropsUpdate ( ) : void {
143- // not mounted yet
144- if ( ! this . parent || isHydrating ) return
145-
146- const mount = ( parent : ParentNode , anchor : Node | null ) => {
147- if ( this . $transition ) {
148- applyTransitionHooks ( this . nodes , this . $transition )
149- }
150- insert (
151- this . nodes ,
152- ( this . mountContainer = parent ) ,
153- ( this . mountAnchor = anchor ) ,
154- )
142+ private mount ( parent : ParentNode , anchor : Node | null ) {
143+ if ( this . $transition ) {
144+ applyTransitionHooks ( this . nodes , this . $transition )
155145 }
146+ insert (
147+ this . nodes ,
148+ ( this . mountContainer = parent ) ,
149+ ( this . mountAnchor = anchor ) ,
150+ )
151+ }
156152
157- const mountToTarget = ( ) => {
158- const target = ( this . target = resolveTeleportTarget (
159- this . resolvedProps ! ,
160- querySelector ,
161- ) )
162- if ( target ) {
163- if (
164- // initial mount into target
165- ! this . targetAnchor ||
166- // target changed
167- this . targetAnchor . parentNode !== target
168- ) {
169- insert ( ( this . targetStart = createTextNode ( '' ) ) , target )
170- insert ( ( this . targetAnchor = createTextNode ( '' ) ) , target )
171- }
172-
173- // track CE teleport targets
174- if ( this . parentComponent && this . parentComponent . isCE ) {
175- ; (
176- this . parentComponent . ce ! . _teleportTargets ||
177- ( this . parentComponent . ce ! . _teleportTargets = new Set ( ) )
178- ) . add ( target )
179- }
153+ private mountToTarget ( ) : void {
154+ const target = ( this . target = resolveTeleportTarget (
155+ this . resolvedProps ! ,
156+ querySelector ,
157+ ) )
158+ if ( target ) {
159+ if (
160+ // initial mount into target
161+ ! this . targetAnchor ||
162+ // target changed
163+ this . targetAnchor . parentNode !== target
164+ ) {
165+ insert ( ( this . targetStart = createTextNode ( '' ) ) , target )
166+ insert ( ( this . targetAnchor = createTextNode ( '' ) ) , target )
167+ }
180168
181- mount ( target , this . targetAnchor ! )
182- updateCssVars ( this )
183- } else if ( __DEV__ ) {
184- warn (
185- `Invalid Teleport target on ${ this . targetAnchor ? 'update' : 'mount' } :` ,
186- target ,
187- `(${ typeof target } )` ,
188- )
169+ // track CE teleport targets
170+ if ( this . parentComponent && this . parentComponent . isCE ) {
171+ ; (
172+ this . parentComponent . ce ! . _teleportTargets ||
173+ ( this . parentComponent . ce ! . _teleportTargets = new Set ( ) )
174+ ) . add ( target )
189175 }
176+
177+ this . mount ( target , this . targetAnchor ! )
178+ updateCssVars ( this )
179+ } else if ( __DEV__ ) {
180+ warn (
181+ `Invalid Teleport target on ${ this . targetAnchor ? 'update' : 'mount' } :` ,
182+ target ,
183+ `(${ typeof target } )` ,
184+ )
190185 }
186+ }
187+
188+ private handlePropsUpdate ( ) : void {
189+ // not mounted yet
190+ if ( ! this . parent || isHydrating ) return
191191
192192 // mount into main container
193193 if ( this . isDisabled ) {
194- mount ( this . parent , this . anchor ! )
194+ this . mount ( this . parent , this . anchor ! )
195195 updateCssVars ( this )
196196 }
197197 // mount into target container
@@ -202,9 +202,9 @@ export class TeleportFragment extends VaporFragment {
202202 // typically due to an early insertion caused by setInsertionState.
203203 ! this . parent ! . isConnected
204204 ) {
205- queuePostFlushCb ( mountToTarget )
205+ queuePostFlushCb ( this . mountToTarget . bind ( this ) )
206206 } else {
207- mountToTarget ( )
207+ this . mountToTarget ( )
208208 }
209209 }
210210 }
@@ -260,7 +260,7 @@ export class TeleportFragment extends VaporFragment {
260260 this . initChildren ( )
261261 }
262262
263- private mount ( target : Node ) : void {
263+ private mountChildren ( target : Node ) : void {
264264 target . appendChild ( ( this . targetStart = createTextNode ( '' ) ) )
265265 target . appendChild (
266266 ( this . mountAnchor = this . targetAnchor = createTextNode ( '' ) ) ,
@@ -319,7 +319,7 @@ export class TeleportFragment extends VaporFragment {
319319 // always be null, we need to manually add targetAnchor to ensure
320320 // Teleport it can properly unmount or move
321321 if ( ! this . targetAnchor ) {
322- this . mount ( target )
322+ this . mountChildren ( target )
323323 } else {
324324 this . initChildren ( )
325325 }
0 commit comments