JS Events that don't bubble (progress, loadedmetadata, etc)

懵懂的女人 提交于 2019-12-13 21:19:18

问题


I found out that certain events on the video/audio tag don't bubble (loadedmetadata, progress, etc). Is this against the standard or is it common for other events?

How am I supposed to know what events are supposed to bubble or not bubble?


回答1:


  1. You can test it...
  2. readonly attribute boolean bubbles; check this property of the event.

bubbles of type boolean, readonly

Used to indicate whether or not an event is a bubbling event. If the event can bubble the value is true, else the value is false.

w3 source not w3School... :)




回答2:


Bubbling events are usually those that need to bubble. Like if you click an element, you are also clicking its parents so it must bubble. But when a progress happens on a media element, it doesn't really happen on its parents the way keyup, click, mouseover etc do.




回答3:


Look in the specs. gdoron already posted a link to them and explained the each Event has an attribute indicating whether it bubbles or not - only useful when you have the event already.

Yet, look further down in that spec: In the Event module definitions there is an overview of events and whether they bubble or not. Also, you will finde more events in the DOM-Level3-Draft.

Also, you asked progress events. They are only a draft, but in the section about proposed events you can find that they are not supposed to bubble.



来源:https://stackoverflow.com/questions/10576167/js-events-that-dont-bubble-progress-loadedmetadata-etc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!