Why don't audio and video events bubble?
Why don't audio and video events bubble?
The reason why event bubbling exists is solve the ambiguous question of which element is the intended target of the event. So, if you click on a div, did you mean to click the div, or its parent? If the child doesn't have a click handler attached, then it checks the parent, and so on. I'm sure you know how that works. The reason why audio events don't bubble is because they don't make sense on any other element. There's no ambiguity when you trigger a timeupdate on an audio element whether it's meant for the audio element itself or its parent div, so there's no need to bubble it. Really, you should attach your event handlers to to lowest element you can, and when it comes to audio and video, you should attach your handlers directly. You can read a fuller history of event bubbling here
沒有留言:
張貼留言