Skip to content

Commit 55dbdd9

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 4671fba commit 55dbdd9

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
@@ -438,7 +438,7 @@ export default class View {
438438
let hook = this.getHook(fromEl)
439439
let isIgnored = hook && DOM.isIgnored(fromEl, this.binding(PHX_UPDATE))
440440
if(hook && !fromEl.isEqualNode(toEl) && !(isIgnored && isEqualObj(fromEl.dataset, toEl.dataset))){
441-
hook.__beforeUpdate()
441+
hook.__beforeUpdate(fromEl, toEl)
442442
return hook
443443
}
444444
}

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)