[DOM Event Learning] Section 4 Event distribution and DOM Event stream, sectiondom

Source: Internet
Author: User

[DOM Event Learning] Section 4 Event distribution and DOM Event stream, sectiondom
[DOM Event Learning] Section 4 event distribution and DOM event stream Event distribution mechanism: event dispatch mechanic. event flow describes how Event objects are transmitted in the data structure.Propagation PathEvent objects is distributed to the event target. The Propagation Path of the event object must be determined before the event target is distributed. the propagation path must be an ordered list, which contains the event target that the event object must pass. for DOM implementation, this propagation path must reflect the hierarchical tree structure of this document. The last element in the path list must be the event target of this event ), all elements before this are called ancestor of the target, and an ancestor closest to the target is called its parent. once the propagation path is determined, it cannot be changed. for DOM implementation, this rule takes effect even if the elements in the propagation path are moved or deleted. in the DOM event stream, during event object distribution, event listeners may change the location of event target in the document. Such changes do not affect the propagation path. the exception thrown in event listener cannot stop or affect the propagation path. The exception cannot be propagated outside the event handler.Event phasesCapture phase: The Event object must be transmitted from the Window to the target's parent. Also called capturing phase. event listeners registered for this phase must handle the Event before it reaches its target.Target phase: The event object must reach its target. it is also called at-target phase. event listeners registered for this phase mush handle the event once it has reached its target. if the event type indicates that it cannot bubble, the event object will stop after this phase is complete.Bubble phase: Bubble stage. the event object starts from the target's parent, reversely transmits it to the ancestor, and finally ends at the Window. also called bubbling phase. event listeners registered for this phase must handle the event after it has reached its target. event object must complete one or more phases. if a phase is not supported or stopped, this phase is ignored. for example, Event. the bubbles attribute is set to false, indicating that the phase is not supported, and the phase is ignored. event. stopPropagation () is called before dispatch, and all phases are ignored.Complete PhaseIn implementation, when pending event targets is in the propagation path of a phase part and the propagation is not stopped by Event. stopPropagation,The event object must complete an event phase following the steps below:First, the implementation must determine the current target. This target must be the next pending event target in the propagation path, starting from the first. For event listeners, this target must be the one registered by listener.Then, the implementation must determine the candidate event listeners of the current target.This must be a list Of all event listener registered on the current target. each listener is sorted by registration order. once determined, the list cannot be changed. adding or removing listener does not affect the candidate event listeners of the current target object.Finally, all candidate event handlers must be processed in sequence in the implementation, and each handler must be stimulated when all of the following conditions are met.: 1. the event object's immediate propagation has not been stopped. 2. this listener has been registered for this event phase. 3. this listener has been registered for this event type. when the propagation path is generated, the eventCapture phaseUpload from Window to document object, inBubble phaseUpload the document Object to Window. After the event completes all phases in the propagation pathEvent. currentTargetMust be set to null,Event. eventPhaseAll other attributes that must be set to 0 (NONE). Event (or other interfaces that inherit the Event) remain unchanged. IncludingEvent.tar getAttribute, which must still point to the event target. DOM Event flow is an application of the above model. all events have completed capture and target phases. whether an event needs to complete bubble phase depends on the type of each event. some event listener may cause distribution of other events. Such events are processed synchronously. that is, the first event propagation will only resume after the newly Caused event is distributed. reference link https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html this article mainly comes from the 3.1 Event dispatch and DOM event flow reference list of this article: https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#references-DOMLS W3C latest standards can see: http://www.w3.org/TR/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.