Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: testing-library/svelte-testing-library
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: jsorb84/svelte-testing-library
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Dec 20, 2023

  1. Update pure.js

    jsorb84 authored Dec 20, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a004c9b View commit details
Showing with 7 additions and 13 deletions.
  1. +7 −13 src/pure.js
20 changes: 7 additions & 13 deletions src/pure.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import {
getQueriesForElement,
prettyDOM
} from '@testing-library/dom'
import { tick } from 'svelte'
import { tick, createRoot } from 'svelte'

const containerCache = new Set()
const componentCache = new Set()
@@ -54,18 +54,15 @@ const render = (
return { props: options }
}

let component = new ComponentConstructor({
let component = createRoot(ComponentConstructor, {
target,
...checkProps(options)
...checkProps(options),
ondestroy: () => componentCache.delete(component)
})

containerCache.add({ container, target, component })
componentCache.add(component)

component.$$.on_destroy.push(() => {
componentCache.delete(component)
})

return {
container,
component,
@@ -74,17 +71,14 @@ const render = (
if (componentCache.has(component)) component.$destroy()

// eslint-disable-next-line no-new
component = new ComponentConstructor({
component = createRoot(ComponentConstructor, {
target,
...checkProps(options)
...checkProps(options),
ondestroy: () => componentCache.delete(component)
})

containerCache.add({ container, target, component })
componentCache.add(component)

component.$$.on_destroy.push(() => {
componentCache.delete(component)
})
},
unmount: () => {
if (componentCache.has(component)) component.$destroy()