事件的handler执行时机:(是在冒泡阶段还是capture阶段执行handler).
  • 通过addEventListener(name’,handler,__指定执行时机__)
  • 默认情况下,是在冒泡阶段执行事件的handler



stopImmediatePropagation 和stopProgagation的区别?

在向指定是元素dispatchEvent后事件的传递分为3个阶段。其中bubble阶段是可选的。



There are three event phases:
  • The capture phase: The event object propagates through the target’s ancestors from the Window to the target’s parent. This phase is also known as the capturing phase.
  • The target phase: The event object arrives at the event object’s event target. This phase is also known as the at-target phase. If the event type indicates that the event doesn’t bubble, then the event object will halt after completion of this phase.
  • The bubble phase: The event object propagates through the target’s ancestors in reverse order, starting with the target’s parent and ending with the Window. This phase is also known as the bubbling phase.

 A phase will be skipped if it is not supported, or if the event object’s propagation has been stopped. For example,
  • if the bubbles attribute is set to false, the bubble phase will be skipped,
  • if stopPropagation() has been called prior to the dispatch, all phases will be skipped





3.事件的传播:冒泡和capture

2019-02-16 23:16:30 0 10
这里是评论

相关推荐