Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
A blocked redraw from an event handler lower in the tree cascades upwards. #1850
If two nested divs both have
It seems that the browser passes the same event object to all handlers up the tree, as part of the bubbling process. Thus, both handlers will have an event object with
This cascading of blocked redraws only occurs in one direction, up the tree. If, instead, we set
This surprised me at first. In some situations, it creates the unfortunate requirement of needing to know whether event handlers lower down in the tree are blocking the redraw.
I'm not sure what the ideal behavior would be, but wanted to at least document the issue. Adding a note to the official documentation might be all that is needed.
Perhaps the more important lesson is to generally avoid designs or logic that depends on redraws being blocked, and use
Here's a codepen to illustrate: https://codepen.io/anon/pen/xdYdXM?editors=0011
I've linked the lines below I identified as relevant when I was looking into it =) I think the fix recommended by @pygy might be a one-liner? Of course then we have to make sure everything else works as expected. I'm guessing this doesn't affect the rest of the
The fix is a one liner, yes. I'd reset
We'll also need a test. I don't know if the DOM mock code implements event bubbling. If it doesn't checking that
Edit: @gyandeeps thanks for the offer, PR most welcome!