Skip to content

Commit

Permalink
patch: deep access error (#514)
Browse files Browse the repository at this point in the history
* patch: deep access error

* Create early-parents-raise.md

---------

Co-authored-by: Jovi De Croock <decroockjovi@gmail.com>
  • Loading branch information
antran22 and JoviDeCroock committed Oct 1, 2023
1 parent a6c9be9 commit 1101d1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/early-parents-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@prefresh/core": patch
---

add guard for undefined component before accessing parentDom
2 changes: 1 addition & 1 deletion packages/core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function replaceComponent(OldType, NewType, resetHookState) {
pendingUpdates = pendingUpdates.filter(p => p[0] !== OldType);

vnodes.forEach(vnode => {
if (!vnode.__c.__P) return;
if (!vnode.__c || !vnode.__c.__P) return;
// update the type in-place to reference the new component
vnode.type = NewType;

Expand Down

0 comments on commit 1101d1f

Please sign in to comment.