1. event.preventDefault只是取消event的默认action, 比如submit event不会产生POST 请求 , 2. event.stopPropagation 会停止 bubble两个phase的dispatch 3.event dispatch分为3个阶段 (eventPhase为0, 0:表示当前event没有被触发调度 1>: capture阶段 2> eventTarget dispatch 阶段, 此时currentEventTarget === eventTarget 3> bubble 阶段, 在html中或者通过DOMNode attribute设置的 on{event} = handler 在这个阶段被调度
-
-
-
- [Event.NONE 0 No event is being processed at this time.
-
-
-
-
- Event.CAPTURING_PHASE
-
-
- 1 The event is being propagated through the target's ancestor objects. This process starts with the Window, then Document, then the HTMLHtmlElement, and so on through the elements until the target's parent is reached. Event listeners registered for capture mode when EventTarget.addEventListener() was called are triggered during this phase.
-
-
-
- Event.AT_TARGET
-
-
- 2 The event has arrived at the event's target. Event listeners registered for this phase are called at this time. If Event.bubbles is false, processing the event is finished after this phase is complete.
-
- 这个阶段,所有注册的event listener都会被执行,及时在当前有一个eventlistener 调用stopPropagation,注意stopPropagation 只是定制 event的调度,但是当前 node上的eventlistener都会一直执行.
-
-
- Event.BUBBLING_PHASE
-
-
- 3 The event is propagating back up through the target's ancestors in reverse order, starting with the parent, and eventually reaching the containing Window. This is known as bubbling, and occurs only if Event.bubbles is true. Event listeners registered for this phase are triggered during this process.]
-
- 在html中通过 on{event} = xxx的方式定义event handler
-
如果在parent node (captured) 中调用了stopPropagation, event不会被调度到 当前node,但是这并不妨碍 当前node执行 defaultaction, 换句话说 如果click event在( input type='submit') 之前被 stopPropagation,但是 <input type='submit'依然能够触发 submit event , 如果想让<input type='submit>不触发submit 只能 在click event handler 中调用 preventDefault()
-
在html 设置on{event}=xxx , "xxx"必须是 functionFoo( args),其中args可以是 "this", "event" 这两个是在DOMnode 的context中