Skip to content

Commit 4ebf9b9

Browse files
committed
Try alternative
1 parent 6ad366f commit 4ebf9b9

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

packages/core/src/runtime/unmount.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ options.unmount = vnode => {
77
if (typeof type === 'function' && vnodesForComponent.has(type)) {
88
const vnodes = vnodesForComponent.get(type);
99
if (vnodes) {
10-
const mountedVnodesForType = vnodes.filter(
11-
p => p.__c && p.__c !== vnode.__c
12-
);
13-
vnodesForComponent.set(vnode.type, mountedVnodesForType);
10+
const index = vnodes.indexOf(vnode);
11+
if (index !== -1) {
12+
vnodes.splice(index, 1);
13+
}
1414
}
1515
}
1616

packages/core/src/runtime/vnode.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import { options } from 'preact';
2-
import { vnodesForComponent, mappedVNodes, lastSeen } from './vnodesForComponent';
2+
import {
3+
vnodesForComponent,
4+
mappedVNodes,
5+
lastSeen,
6+
} from './vnodesForComponent';
37
import { VNODE_COMPONENT } from '../constants';
48

59
const getMappedVnode = type => {
@@ -13,11 +17,11 @@ const getMappedVnode = type => {
1317
const BUILT_IN_COMPONENTS = ['Fragment', 'Suspense', 'SuspenseList'];
1418

1519
const isBuiltIn = type => {
16-
return BUILT_IN_COMPONENTS.includes(type.name)
17-
}
20+
return BUILT_IN_COMPONENTS.includes(type.name);
21+
};
1822

19-
const oldVnode = options.vnode;
20-
options.vnode = vnode => {
23+
const oldVnode = options.__b;
24+
options.__b = vnode => {
2125
if (vnode && typeof vnode.type === 'function' && !isBuiltIn(vnode.type)) {
2226
const vnodes = vnodesForComponent.get(vnode.type);
2327
if (!vnodes) {

0 commit comments

Comments
 (0)