Skip to content

Commit 69cc407

Browse files
committed
pass fromEl and toEl to hook beforeUpdate
Relates to #3615. Allowing beforeUpdate to cancel an update by returning false is **not** implemented, as this would require more complex internal changes.
1 parent fbed65d commit 69cc407

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

assets/js/phoenix_live_view/view.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export default class View {
458458
let hook = this.getHook(fromEl)
459459
let isIgnored = hook && DOM.isIgnored(fromEl, this.binding(PHX_UPDATE))
460460
if(hook && !fromEl.isEqualNode(toEl) && !(isIgnored && isEqualObj(fromEl.dataset, toEl.dataset))){
461-
hook.__beforeUpdate()
461+
hook.__beforeUpdate(fromEl, toEl)
462462
return hook
463463
}
464464
}

assets/js/phoenix_live_view/view_hook.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default class ViewHook {
3232

3333
__mounted(){ this.mounted && this.mounted() }
3434
__updated(){ this.updated && this.updated() }
35-
__beforeUpdate(){ this.beforeUpdate && this.beforeUpdate() }
35+
__beforeUpdate(fromEl, toEl){ this.beforeUpdate && this.beforeUpdate(fromEl, toEl) }
3636
__destroyed(){
3737
this.destroyed && this.destroyed()
3838
DOM.deletePrivate(this.el, HOOK_ID) // https://github.com/phoenixframework/phoenix_live_view/issues/3496

0 commit comments

Comments
 (0)