File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -3,9 +3,10 @@ import {
33 getQueriesForElement ,
44 prettyDOM ,
55} from '@testing-library/dom'
6+ import { VERSION as SVELTE_VERSION } from 'svelte/compiler'
67import * as Svelte from 'svelte'
78
8- const IS_SVELTE_5 = typeof Svelte . createRoot === 'function'
9+ const IS_SVELTE_5 = / ^ 5 \. / . test ( SVELTE_VERSION )
910const targetCache = new Set ( )
1011const componentCache = new Set ( )
1112
@@ -55,7 +56,7 @@ const render = (
5556 options = { target, ...checkProps ( options ) }
5657
5758 const component = IS_SVELTE_5
58- ? Svelte . createRoot ( ComponentConstructor , options )
59+ ? Svelte . mount ( ComponentConstructor , options )
5960 : new ComponentConstructor ( options )
6061
6162 componentCache . add ( component )
@@ -98,7 +99,11 @@ const cleanupComponent = (component) => {
9899 const inCache = componentCache . delete ( component )
99100
100101 if ( inCache ) {
101- component . $destroy ( )
102+ if ( IS_SVELTE_5 ) {
103+ Svelte . unmount ( component )
104+ } else {
105+ component . $destroy ( )
106+ }
102107 }
103108}
104109
You can’t perform that action at this time.
0 commit comments