Skip to content

Commit

Permalink
Avoid memory leak (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock authored Nov 16, 2024
1 parent 21b92ac commit 06f97ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/blue-rocks-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@prefresh/core': patch
---

Avoid memory leak by not registering built-in types
8 changes: 7 additions & 1 deletion packages/core/src/runtime/vnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ const getMappedVnode = type => {
return type;
};

const BUILT_IN_COMPONENTS = ['Fragment', 'Suspense', 'SuspenseList'];

const isBuiltIn = type => {
return BUILT_IN_COMPONENTS.includes(type.name)
}

const oldVnode = options.vnode;
options.vnode = vnode => {
if (vnode && typeof vnode.type === 'function') {
if (vnode && typeof vnode.type === 'function' && !isBuiltIn(vnode.type)) {
const vnodes = vnodesForComponent.get(vnode.type);
if (!vnodes) {
vnodesForComponent.set(vnode.type, [vnode]);
Expand Down

0 comments on commit 06f97ac

Please sign in to comment.