How does event handling work internally within JavaScript?

后端 未结 2 539
谎友^
谎友^ 2020-12-14 11:24

Specifically Spidermonkey.

I know you write functions and attach them to events to handle them.

Where is the onClick handler defined and how do

2条回答
  •  余生分开走
    2020-12-14 12:04

    1. HTML uses sink/bubble event propagation schema: http://catcode.com/domcontent/events/capture.html
    2. There are "physical" events (mouse, keyboard) and logical/synthesized ones (focus,click, value_changed, etc.)
    3. onClick is a logical event - generated as a result of mouse, touch and/or keyboard events.
    4. Mouse (or finger touch) originated click event is a result of mouse down, move and up events. Note that mouse down, move and up are sinking/bubbling events. Target element(s) in these "primordial" events will be the target(or source) of the click event. If mouse-down/up events have different targets (DOM element) then their common parent is used.
    5. Sequence of mouse down, move and up events may produce different logical events: click, swipe/scroll, etc.

    I believe this is a full list of basic concepts.

提交回复
热议问题