Skip to content

Commit

Permalink
clear private HOOK_ID as soon as hook is destroyed
Browse files Browse the repository at this point in the history
Fixes #3496.

When navigating from a sticky LiveView to another page that contains
a hook on an element with the same id, morphdom would merge the old
element into the new one and still find the old HOOK_ID in the element's
DOM.private data, leading to the new hook not initalizing properly.
  • Loading branch information
SteffenDE committed Nov 11, 2024
1 parent 2869e28 commit 064660f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion assets/js/phoenix_live_view/view_hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export default class ViewHook {
__mounted(){ this.mounted && this.mounted() }
__updated(){ this.updated && this.updated() }
__beforeUpdate(){ this.beforeUpdate && this.beforeUpdate() }
__destroyed(){ this.destroyed && this.destroyed() }
__destroyed(){
this.destroyed && this.destroyed()
DOM.deletePrivate(this.el, HOOK_ID) // https://github.com/phoenixframework/phoenix_live_view/issues/3496
}
__reconnected(){
if(this.__isDisconnected){
this.__isDisconnected = false
Expand Down

0 comments on commit 064660f

Please sign in to comment.