Skip to content

Commit 0d8672c

Browse files
committed
fix: always destroy most recent component on rerender
1 parent 3abc678 commit 0d8672c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/pure.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const render = (
4949
return { props: options }
5050
}
5151

52-
const component = new ComponentConstructor({
52+
let component = new ComponentConstructor({
5353
target,
5454
...checkProps(options)
5555
})
@@ -67,15 +67,15 @@ const render = (
6767
if (componentCache.has(component)) component.$destroy()
6868

6969
// eslint-disable-next-line no-new
70-
const newComponent = new ComponentConstructor({
70+
component = new ComponentConstructor({
7171
target,
7272
...checkProps(options)
7373
})
7474

75-
containerCache.set(container, { target, newComponent })
76-
componentCache.add(newComponent)
75+
containerCache.set(container, { target, component })
76+
componentCache.add(component)
7777

78-
newComponent.$$.on_destroy.push(() => { componentCache.delete(newComponent) })
78+
component.$$.on_destroy.push(() => { componentCache.delete(component) })
7979
},
8080
unmount: () => {
8181
if (componentCache.has(component)) component.$destroy()

0 commit comments

Comments
 (0)