This repository has been archived by the owner on Nov 11, 2019. It is now read-only.
forked from whatwg/dom
/
Overview.src.html
8998 lines (7270 loc) · 395 KB
/
Overview.src.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html><html lang=en-US><meta charset=utf-8>
<title>DOM Standard</title>
<link rel=stylesheet href=//whatwg.org/style/specification>
<link rel=icon href=//resources.whatwg.org/logo-dom.svg>
<div class=head>
<p><a class=logo href=//whatwg.org/><img alt=WHATWG src=//resources.whatwg.org/logo-dom.svg width=100 height=100></a></p>
<hgroup>
<h1 class=allcaps>DOM</h1>
<h2>Living Standard — Last Updated [DATE: 01 Jan 1901]</h2>
</hgroup>
<dl>
<dt>Participate:</dt>
<dd class=dontpublish>Send feedback to
<a href="mailto:www-dom@w3.org?subject=DOM%3A%20">www-dom@w3.org</a> (<a href="http://lists.w3.org/Archives/Public/www-dom/">archives</a>) or
<a href="https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WebAppsWG&component=DOM">file a bug</a>
(<a href="https://www.w3.org/Bugs/Public/buglist.cgi?product=WebAppsWG&component=DOM&resolution=---">open bugs</a>)
<dd class=dontpublish><a href="//wiki.whatwg.org/wiki/IRC">IRC: #whatwg on Freenode</a>
<dt>Version History:
<dd><a href=https://github.com/whatwg/dom/commits>https://github.com/whatwg/dom/commits</a>
<dd><a href="https://twitter.com/thedomstandard">@thedomstandard</a>
</dl>
<script src=//resources.whatwg.org/file-bug.js async></script>
</div>
<h2 class="no-num no-toc">Abstract</h2>
<p>DOM defines a platform-neutral model for events and node trees.
<h2 class="no-num no-toc">Table of Contents</h2>
<!--toc-->
<h2 class=no-num>Goals</h2>
<p>This specification standardizes the DOM. It does so as follows:</p>
<ol>
<li>
<p>By consolidating <cite>DOM Level 3 Core</cite>
<span data-anolis-ref class=informative>DOM3CORE</span>,
<cite>Element Traversal</cite>
<span data-anolis-ref class=informative>ELEMENTTRAVERSAL</span>,
<cite>Selectors API Level 2</cite>
<span data-anolis-ref class=informative>SELECTORSAPI</span>, the
"DOM Event Architecture" and "Basic Event Interfaces" chapters of
<cite>DOM Level 3 Events</cite>
<span data-anolis-ref class=informative>DOM3EVENTS</span> (specific type
of events do not belong in the base specification), and
<cite>DOM Level 2 Traversal and Range</cite>
<span data-anolis-ref class=informative>DOM2TR</span>, and:
<ul>
<li>Aligning them with the needs of JavaScript where possible.
<li>Aligning them with existing implementations.
<li>Simplifying them as much as possible.
</ul>
<li><p>By moving features from the HTML standard that ought to be part of the DOM
platform here. <span data-anolis-ref>HTML</span>
<li>
<p>By defining a replacement for the "Mutation Events" and
"Mutation Name Event Types" chapters of <cite>DOM Level 3 Events</cite>
<span data-anolis-ref class=informative>DOM3EVENTS</span> as the old model
was problematic.
<p class=note>The old model is expected to be removed from implementations
in due course.
<li><p>By defining new features that simplify common DOM operations.
</ol>
<h2>Conformance</h2>
<p>All diagrams, examples, and notes in this specification are
non-normative, as are all sections explicitly marked non-normative.
Everything else in this specification is normative.
<p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in RFC 2119.
For readability, these words do not appear in all uppercase letters in this
specification. <span data-anolis-ref>RFC2119</span>
<p>Requirements phrased in the imperative as part of algorithms
(such as "strip any leading space characters" or "return false and
terminate these steps") are to be interpreted with the meaning of the
key word ("must", "should", "may", etc) used in introducing the
algorithm.
<p>Conformance requirements phrased as algorithms or specific steps
may be implemented in any manner, so long as the end result is
equivalent. (In particular, the algorithms defined in this
specification are intended to be easy to follow, and not intended to
be performant.)
<p id="hardwareLimitations">User agents may impose
implementation-specific limits on otherwise unconstrained inputs,
e.g. to prevent denial of service attacks, to guard against running
out of memory, or to work around platform-specific limitations.
<p>When a method or an attribute is said to call another method or attribute, the user agent must invoke its internal API for that attribute or method so that e.g. the author can't change the behavior by overriding attributes or methods with custom properties or functions in JavaScript.
<p>Unless otherwise stated, string comparisons are done in a <span>case-sensitive</span> manner.
<h3>Dependencies</h3>
<p>The IDL fragments in this specification must be interpreted as
required for conforming IDL fragments, as described in the Web IDL
specification. <span data-anolis-ref>WEBIDL</span>
<p>Some of the terms used in this specification are defined in
<cite>Encoding</cite>, <cite>Selectors</cite>, <cite>Web IDL</cite>, <cite>XML</cite>, and
<cite>Namespaces in XML</cite>.
<span data-anolis-ref>ENCODING</span>
<span data-anolis-ref>SELECTORS</span>
<span data-anolis-ref>WEBIDL</span>
<span data-anolis-ref>XML</span>
<span data-anolis-ref>XMLNS</span>
<h3>Extensibility</h3>
<p>Vendor-specific proprietary extensions to this specification are
strongly discouraged. Authors must not use such extensions, as
doing so reduces interoperability and fragments the user base,
allowing only users of specific user agents to access the content in
question.
<p>If vendor-specific extensions are needed, the members should be
prefixed by vendor-specific strings to prevent clashes with future
versions of this specification. Extensions must be defined so that
the use of extensions neither contradicts nor causes the
non-conformance of functionality defined in the specification.
<!-- thanks to QA Framework -->
<p>When vendor-neutral extensions to this specification are needed,
either this specification can be updated accordingly, or an
extension specification can be written that overrides the
requirements in this specification. When someone applying this
specification to their activities decides that they will recognize
the requirements of such an extension specification, it becomes an
<dfn title="other applicable specifications">applicable
specification</dfn> for the purposes of conformance requirements in
this specification.
<!-- http://www.w3.org/mid/17E341CD-E790-422C-9F9A-69347EE01CEB@iki.fi -->
<h2>Terminology</h2>
<p>The term <dfn>context object</dfn> means the object on which the algorithm,
attribute getter, attribute setter, or method being discussed was called. When the
<span>context object</span> is unambiguous, the term can be omitted.
<!-- XXX we should prolly explain that "set attribute X to Y" works even for
readonly attributes when it is language for implementors -->
<h3>Trees</h3> <!-- Sorry reddit, this is not /r/trees -->
<p>A <dfn title=concept-tree>tree</dfn> is a finite hierarchical tree structure. In
<dfn title=concept-tree-order>tree order</dfn> is preorder, depth-first
traversal of a <span title=concept-tree>tree</span>.
<!-- http://en.wikipedia.org/wiki/Tree_traversal#Depth-first_Traversal -->
<p>An object that <dfn title=concept-tree-participate>participates</dfn> in
a <span title=concept-tree>tree</span> has a
<dfn title=concept-tree-parent>parent</dfn>, which is either another object
or null, and an ordered list of zero or more
<dfn title=concept-tree-child>child</dfn> objects. An object <var title>A</var> whose
<span title=concept-tree-parent>parent</span> is object <var title>B</var> is a
<span title=concept-tree-child>child</span> of <var title>B</var>.
<p>The <dfn title=concept-tree-root>root</dfn> of an object is itself, if its
<span title=concept-tree-parent>parent</span> is null, or else it is the
<span title=concept-tree-root>root</span> of its
<span title=concept-tree-parent>parent</span>.
<p>An object <var title>A</var> is called a
<dfn title=concept-tree-descendant>descendant</dfn> of an object
<var title>B</var>, if either <var title>A</var> is a
<span title=concept-tree-child>child</span> of <var title>B</var> or
<var title>A</var> is a <span title=concept-tree-child>child</span> of an
object <var title>C</var> that is a
<span title=concept-tree-descendant>descendant</span> of <var title>B</var>.
<p>An
<dfn title=concept-tree-inclusive-descendant>inclusive descendant</dfn> is
an object or one of its
<span title=concept-tree-descendant>descendants</span>.
<p>An object <var title>A</var> is called an
<dfn title=concept-tree-ancestor>ancestor</dfn> of an object
<var title>B</var> if and only if <var title>B</var> is a
<span title=concept-tree-descendant>descendant</span> of
<var title>A</var>.
<p>An <dfn title=concept-tree-inclusive-ancestor>inclusive ancestor</dfn> is
an object or one of its <span title=concept-tree-ancestor>ancestors</span>.
<p>An object <var title>A</var> is called a
<dfn title=concept-tree-sibling>sibling</dfn> of an object
<var title>B</var>, if and only if <var title>B</var> and <var title>A</var>
share the same non-null <span title=concept-tree-parent>parent</span>.
<p>An object <var title>A</var> is
<dfn title=concept-tree-preceding>preceding</dfn> an object
<var title>B</var> if <var title>A</var> and <var title>B</var> are in the
same <span title=concept-tree>tree</span> and <var title>A</var> comes
before <var title>B</var> in
<span title=concept-tree-order>tree order</span>.
<p>An object <var title>A</var> is
<dfn title=concept-tree-following>following</dfn> an object
<var title>B</var> if <var title>A</var> and <var title>B</var> are in the
same <span title=concept-tree>tree</span> and <var title>A</var> comes
after <var title>B</var> in
<span title=concept-tree-order>tree order</span>.
<p>The <dfn title=concept-tree-first-child>first child</dfn> of an object is
its first <span title=concept-tree-child>child</span> or null if it has no
<span title=concept-tree-child>child</span>.
<p>The <dfn title=concept-tree-last-child>last child</dfn> of an object is
its last <span title=concept-tree-child>child</span> or null if it has no
<span title=concept-tree-child>child</span>.
<p>The <dfn title=concept-tree-previous-sibling>previous sibling</dfn> of an
object is its first <span title=concept-tree-preceding>preceding</span>
<span title=concept-tree-sibling>sibling</span> or null if it has no
<span title=concept-tree-preceding>preceding</span>
<span title=concept-tree-sibling>sibling</span>.
<p>The <dfn title=concept-tree-next-sibling>next sibling</dfn> of an
object is its first <span title=concept-tree-following>following</span>
<span title=concept-tree-sibling>sibling</span> or null if it has no
<span title=concept-tree-following>following</span>
<span title=concept-tree-sibling>sibling</span>.
<p>The <dfn title=concept-tree-index>index</dfn> of an object is its number
of <span title=concept-tree-preceding>preceding</span>
<span title=concept-tree-sibling>siblings</span>.
<h3>Strings</h3>
<p>Comparing two strings in a <dfn>case-sensitive</dfn> manner means comparing them exactly, code point for code point.
<p>Comparing two strings in a <dfn>ASCII case-insensitive</dfn> manner means comparing them exactly, code point for code point, except that the characters in the range U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range U+0061 .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also match.
<p><dfn title="converted to ascii uppercase">Converting a string to ASCII uppercase</dfn> means replacing all characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) with the corresponding characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).
<p><dfn title="converted to ascii lowercase">Converting a string to ASCII lowercase</dfn> means replacing all characters in the range U+0041 to U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) with the corresponding characters in the range U+0061 to U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z).
<p>A string <var title>pattern</var> is a <dfn>prefix match</dfn> for a string
<var title>s</var> when <var title>pattern</var> is not longer than
<var title>s</var> and truncating <var title>s</var> to
<var title>pattern</var>'s length leaves the two strings as matches of each
other.
<h3>Ordered sets</h3>
<p>The <dfn title=concept-ordered-set-parser>ordered set parser</dfn> takes a string
<var title>input</var> and then runs these steps:
<ol>
<li><p>Let <var title>position</var> be a pointer into <var title>input</var>,
initially pointing at the start of the string.
<li><p>Let <var title>tokens</var> be an ordered set of tokens, initially empty.
<li><p><span>Skip ASCII whitespace</span>.
<li><p>While <var title>position</var> is not past the end of
<var title>input</var>:
<ol>
<li><p><span>Collect a code point sequence</span> of code points that are
not <span data-anolis-spec=encoding>ASCII whitespace</span>.
<li><p>If the collected string is not in <var title>tokens</var>, append the
collected string to <var title>tokens</var>.
<li><p><span>Skip ASCII whitespace</span>.
</ol>
<li><p>Return <var title>tokens</var>.
</ol>
<p>To <dfn>collect a code point sequence</dfn> of
<var title>code points</var>, run these steps:
<ol>
<li><p>Let <var title>input</var> and <var title>position</var> be the same
variables as those of the same name in the algorithm that invoked these
steps.
<li><p>Let <var title>result</var> be the empty string.
<li><p>While <var title>position</var> does not point past the end of
<var title>input</var> and the code point at <var title>position</var> is
one of <var title>code points</var>, append that code point to the end
of <var title>result</var> and advance <var title>position</var> to the
next code point in <var title>input</var>.
<li><p>Return <var title>result</var>.
</ol>
<p>To <dfn>skip ASCII whitespace</dfn> means to
<span>collect a code point sequence</span> of
<span data-anolis-spec=encoding>ASCII whitespace</span> and discard the
return value.
<p>The <dfn title=concept-ordered-set-serializer>ordered set serializer</dfn> takes a
<var title>set</var> and returns the concatenation of the strings in
<var title>set</var>, separated from each other by U+0020.
<h3>Namespaces</h3>
<p>The <dfn>HTML namespace</dfn> is
<code title>http://www.w3.org/1999/xhtml</code>.
<p>The <dfn>XML namespace</dfn> is
<code title>http://www.w3.org/XML/1998/namespace</code>.
<p>The <dfn>XMLNS namespace</dfn> is
<code title>http://www.w3.org/2000/xmlns/</code>.
<h2>Events</h2>
<h3>Introduction to "DOM Events"</h3>
<p>Throughout the web platform <span title=concept-event>events</span> are
<span title=concept-event-dispatch>dispatched</span> to objects to signal an
occurrence, such as network activity or user interaction. These objects
implement the <code>EventTarget</code> interface and can therefore add
<span title=concept-event-listener>event listeners</span> to observe
<span title=concept-event>events</span>:
<pre><code>obj.addEventListener("load", imgFetched)
function imgFetched(ev) {
// great success
…
}</code></pre>
<p><span title=concept-event-listener>Event listeners</span> can be removed
by utilizing the
<code title=dom-EventTarget-removeEventListener>removeEventListener()</code>
method, passing the same arguments.
<p><span title=concept-event>Events</span> are objects too and implement the
<code>Event</code> interface (or a derived interface). In the example above
<var title>ev</var> is the <span title=concept-event>event</span>. It is
passed as argument to
<span title=concept-event-listener>event listener</span>'s <b>callback</b>
(typically a JavaScript Function as shown above).
<span title=concept-event-listener>Event listeners</span> key off the
<span title=concept-event>event</span>'s
<code title=dom-Event-type>type</code> attribute value
("<code title>load</code>" in the above example). The
<span title=concept-event>event</span>'s
<code title=dom-Event-target>target</code> attribute value returns the
object to which the <span title=concept-event>event</span> was
<span title=concept-event-dispatch>dispatched</span> (<var title>obj</var>
above).
<p>Now while typically <span title=concept-event>events</span> are
<span title=concept-event-dispatch>dispatched</span> by the user agent as
the result of user interaction or the completion of some task, applications
can <span title=concept-event-dispatch>dispatch</span>
<span title=concept-event>events</span> themselves, commonly known as
synthetic events:
<pre><code>// add an appropriate event listener
obj.addEventListener("cat", function(e) { process(e.detail) })
// create and dispatch the event
var event = new CustomEvent("cat", {"detail":{"hazcheeseburger":true}})
obj.dispatchEvent(event)</code></pre>
<p>Apart from signaling, <span title=concept-event>events</span> are
sometimes also used to let an application control what happens next in an
operation. For instance as part of form submission an
<span title=concept-event>event</span> whose
<code title=dom-Event-type>type</code> attribute value is
"<code title>submit</code>" is
<span title=concept-event-dispatch>dispatched</span>. If this
<span title=concept-event>event</span>'s
<code title=dom-Event-preventDefault>preventDefault()</code> method is
invoked, form submission will be terminated. Applications who wish to make
use of this functionality through <span title=concept-event>events</span>
<span title=concept-event-dispatch>dispatched</span> by the application
(synthetic events) can make use of the return value of the
<code title=dom-EventTarget-dispatchEvent>dispatchEvent()</code> method:
<pre><code>if(obj.dispatchEvent(event)) {
// event was not canceled, time for some magic
…
}</code></pre>
<p>When an <span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span> to an object that
<span title=concept-tree-participate>participates</span> in a
<span title=concept-tree>tree</span> (e.g. an
<span title=concept-element>element</span>), it can reach
<span title=concept-event-listener>event listeners</span> on that object's
<span title=concept-tree-ancestor>ancestors</span> too. First all object's
<span title=concept-tree-ancestor>ancestor</span>
<span title=concept-event-listener>event listeners</span> whose
<b>capture</b> variable is set to true are invoked, in
<span title=concept-tree-order>tree order</span>. Second, object's own
<span title=concept-event-listener>event listeners</span> are invoked. And
finally, and only if <span title=concept-event>event</span>'s
<span title=dom-Event-bubbles>bubbles</span> attribute value is true,
object's <span title=concept-tree-ancestor>ancestor</span>
<span title=concept-event-listener>event listeners</span> are invoked again,
but now in reverse <span title=concept-tree-order>tree order</span>.
<p>Lets look at an example on how <span title=concept-event>events</span>
work in a <span title=concept-tree>tree</span>:
<pre><code><!doctype html>
<html>
<head>
<title>Boring example</title>
</head>
<body>
<p>Hello <span id=x>world</span>!</p>
<script>
function test(e) {
debug(e.target, e.currentTarget, e.eventPhase)
}
document.addEventListener("hey", test, true)
document.body.addEventListener("hey", test)
var ev = new Event("hey", {bubbles:true})
document.getElementById("x").dispatchEvent(ev)
</script>
</body>
</html></code></pre>
<p>The <code title>debug</code> function will be invoked twice. Each time
the <span title=concept-event>events</span>'s
<code title=dom-Event-target>target</code> attribute value will be the
<code title>span</code> <span title=concept-element>element</span>. The
first time <code title=dom-Event-target>currentTarget</code> attribute's
value will be the <span title=concept-document>document</span>, the second
time the <code title>body</code> <span title=concept-element>element</span>.
<code title=dom-Event-eventPhase>eventPhase</code> attribute's value
switches from <code title=dom-Event-CAPTURING_PHASE>CAPTURING_PHASE</code>
to <code title=dom-Event-BUBBLING_PHASE>BUBBLING_PHASE</code>. If an
<span title=concept-event-listener>event listener</span> was registered for
the <code title>span</code> <span title=concept-element>element</span>,
<code title=dom-Event-eventPhase>eventPhase</code> attribute's value
would have been <code title=dom-Event-AT_TARGET>AT_TARGET</code>.
<h3>Interface <code>Event</code></h3>
<pre class="idl">[<span title=concept-event-constructor>Constructor</span>(DOMString <var title>type</var>, optional <span>EventInit</span> <var title>eventInitDict</var>),
Exposed=(Window,Worker)]
interface <dfn>Event</dfn> {
readonly attribute DOMString <span title=dom-Event-type>type</span>;
readonly attribute <span>EventTarget</span>? <span title=dom-Event-target>target</span>;
readonly attribute <span>EventTarget</span>? <span title=dom-Event-currentTarget>currentTarget</span>;
const unsigned short <span title=dom-Event-NONE>NONE</span> = 0;
const unsigned short <span title=dom-Event-CAPTURING_PHASE>CAPTURING_PHASE</span> = 1;
const unsigned short <span title=dom-Event-AT_TARGET>AT_TARGET</span> = 2;
const unsigned short <span title=dom-Event-BUBBLING_PHASE>BUBBLING_PHASE</span> = 3;
readonly attribute unsigned short <span title=dom-Event-eventPhase>eventPhase</span>;
void <span title=dom-Event-stopPropagation>stopPropagation</span>();
void <span title=dom-Event-stopImmediatePropagation>stopImmediatePropagation</span>();
readonly attribute boolean <span title=dom-Event-bubbles>bubbles</span>;
readonly attribute boolean <span title=dom-Event-cancelable>cancelable</span>;
void <span title=dom-Event-preventDefault>preventDefault</span>();
readonly attribute boolean <span title=dom-Event-defaultPrevented>defaultPrevented</span>;
[Unforgeable] readonly attribute boolean <span title=dom-Event-isTrusted>isTrusted</span>;
readonly attribute DOMTimeStamp <span title=dom-Event-timeStamp>timeStamp</span>;
void <span title=dom-Event-initEvent>initEvent</span>(DOMString <var title>type</var>, boolean <var title>bubbles</var>, boolean <var title>cancelable</var>);
};
dictionary <dfn>EventInit</dfn> {
boolean <span title=dom-EventInit-bubbles>bubbles</span> = false;
boolean <span title=dom-EventInit-cancelable>cancelable</span> = false;
};</pre>
<p>An <dfn title=concept-event>event</dfn> allows for signaling that
something has occurred. E.g. that an image has completed downloading. It is
represented by the <code>Event</code> interface or an interface that
inherits from the <code>Event</code> interface.</p>
<dl class=domintro>
<dt><code><var title>event</var> = new <span title=concept-event-constructor>Event</span>(<var title>type</var> [, <var title>eventInitDict</var>])</code>
<dd><p>Returns a new <var title>event</var> whose
<code title=dom-Event-type>type</code> attribute value is set to
<var title>type</var>. The optional <var title>eventInitDict</var> argument
allows for setting the <code title=dom-Event-bubbles>bubbles</code> and
<code title=dom-Event-cancelable>cancelable</code> attributes via object
members of the same name.
<dt><code><var title>event</var> . <span title=dom-Event-type>type</span></code>
<dd><p>Returns the type of <var title>event</var>, e.g.
"<code title>click</code>", "<code title>hashchange</code>", or
"<code title>submit</code>".
<dt><code><var title>event</var> . <span title=dom-Event-target>target</span></code>
<dd><p>Returns the object <var title>event</var> is
<span title=concept-event-dispatch>dispatched</span> to.
<dt><code><var title>event</var> . <span title=dom-Event-currentTarget>currentTarget</span></code>
<dd><p>Returns the object whose
<span title=concept-event-listener>event listener</span>'s <b>callback</b>
is invoked.
<dt><code><var title>event</var> . <span title=dom-Event-eventPhase>eventPhase</span></code>
<dd><p>Returns the <span title=concept-event>event</span>'s phase, which is
one of <code title=dom-Event-NONE>NONE</code>,
<code title=dom-Event-CAPTURING_PHASE>CAPTURING_PHASE</code>,
<code title=dom-Event-AT_TARGET>AT_TARGET</code>, and
<code title=dom-Event-BUBBLING_PHASE>BUBBLING_PHASE</code>.
<dt><code><var title>event</var> . <span title=dom-Event-stopPropagation>stopPropagation</span>()</code>
<dd><p>When <span title=concept-event-dispatch>dispatched</span> in a
<span title=concept-tree>tree</span>, invoking this method prevents
<var title>event</var> from reaching any other objects than the current.
<dt><code><var title>event</var> . <span title=dom-Event-stopImmediatePropagation>stopImmediatePropagation</span>()</code>
<dd><p>Invoking this method prevents <var title>event</var> from reaching
any <span title=concept-event-listener>event listeners</span> registered
after the current one and when
<span title=concept-event-dispatch>dispatched</span> in a
<span title=concept-tree>tree</span> also prevents
<var title>event</var> from reaching any other objects.
<dt><code><var title>event</var> . <span title=dom-Event-bubbles>bubbles</span></code>
<dd><p>Returns true if <var title>event</var>'s goes through its <code title=dom-Event-target>target</code> attribute value's <span title=concept-tree-ancestor>ancestors</span> in reverse <span title=concept-tree-order>tree order</span>, and false otherwise.
<dt><code><var title>event</var> . <span title=dom-Event-cancelable>cancelable</span></code>
<dd><p>Returns true or false depending on how <var title>event</var> was
initialized. Its return value does not always carry meaning, but true can
indicate that part of the operation during which <var title>event</var> was
<span title=concept-event-dispatch>dispatched</span>, can be canceled by
invoking the <code title=dom-Event-preventDefault>preventDefault()</code>
method.
<dt><code><var title>event</var> . <span title=dom-Event-preventDefault>preventDefault</span>()</code>
<dd><p>If invoked when the
<code title=dom-Event-cancelable>cancelable</code> attribute value is true,
signals to the operation that caused <var title>event</var> to be
<span title=concept-event-dispatch>dispatched</span> that it needs to be
canceled.
<dt><code><var title>event</var> . <span title=dom-Event-defaultPrevented>defaultPrevented</span></code>
<dd><p>Returns true if
<code title=dom-Event-preventDefault>preventDefault()</code> was invoked
while the <code title=dom-Event-cancelable>cancelable</code> attribute
value is true, and false otherwise.
<dt><code><var title>event</var> . <span title=dom-Event-isTrusted>isTrusted</span></code>
<dd><p>Returns true if <var title>event</var> was
<span title=concept-event-dispatch>dispatched</span> by the user agent, and
false otherwise.
<dt><code><var title>event</var> . <span title=dom-Event-timeStamp>timeStamp</span></code>
<dd><p>Returns the creation time of <var title>event</var> in the number of
milliseconds that passed since 00:00:00 UTC on 1 January 1970.
<!-- initEvent is dead -->
</dl>
<p>The <dfn title=dom-Event-type><code>type</code></dfn> attribute must
return the value it was initialized to. When an
<span title=concept-event>event</span> is created the attribute must be
initialized to the empty string.
<p>The <dfn title=dom-Event-target><code>target</code></dfn> and
<dfn title=dom-Event-currentTarget><code>currentTarget</code></dfn>
attributes must return the values they were initialized to. When an
<span title=concept-event>event</span> is created the attributes must be
initialized to null.
<p>The <dfn title=dom-Event-eventPhase><code>eventPhase</code></dfn>
attribute must return the value it was initialized to, which must be one of
the following:</p>
<dl>
<dt><dfn title=dom-Event-NONE><code>NONE</code></dfn> (numeric value 0)
<dd><p><span title=concept-event>Events</span> not currently
<span title=concept-event-dispatch>dispatched</span> are in this phase.
<dt><dfn title=dom-Event-CAPTURING_PHASE><code>CAPTURING_PHASE</code></dfn> (numeric value 1)</dt>
<dd><p>When an <span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span> to an object that
<span title=concept-tree-participate>participates</span> in a
<span title=concept-tree>tree</span> it will be in this phase before it
reaches its <code title=dom-Event-target>target</code> attribute value.
<dt><dfn title=dom-Event-AT_TARGET><code>AT_TARGET</code></dfn> (numeric value 2)
<dd><p>When an <span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span> it will be in this
phase on its <code title=dom-Event-target>target</code> attribute value.
<dt><dfn title=dom-Event-BUBBLING_PHASE><code>BUBBLING_PHASE</code></dfn> (numeric value 3)
<dd><p>When an <span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span> to an object that
<span title=concept-tree-participate>participates</span> in a
<span title=concept-tree>tree</span> it will be in this phase after it
reaches its <code title=dom-Event-target>target</code> attribute value.
</dl>
<p>Initially the attribute must be initialized to
<code title=dom-Event-NONE>NONE</code>.
<hr>
<p>Each <span title=concept-event>event</span> has the following associated
flags that are all initially unset:</p>
<ul>
<li><dfn>stop propagation flag</dfn>
<li><dfn>stop immediate propagation flag</dfn>
<li><dfn>canceled flag</dfn>
<li><dfn>initialized flag</dfn>
<li><dfn>dispatch flag</dfn>
</ul>
<p>The
<dfn title=dom-Event-stopPropagation><code>stopPropagation()</code></dfn>
method must set the <span>stop propagation flag</span>.
<p>The
<dfn title=dom-Event-stopImmediatePropagation><code>stopImmediatePropagation()</code></dfn>
method must set both the <span>stop propagation flag</span> and
<span>stop immediate propagation flag</span>.
<p>The <dfn title=dom-Event-bubbles><code>bubbles</code></dfn> and
<dfn title=dom-Event-cancelable><code>cancelable</code></dfn> attributes
must return the values they were initialized to.
<p>The
<dfn title=dom-Event-preventDefault><code>preventDefault()</code></dfn>
method must set the <span>canceled flag</span> if the
<code title=dom-Event-cancelable>cancelable</code> attribute value is true.
<p>The
<dfn title=dom-Event-defaultPrevented><code>defaultPrevented</code></dfn>
attribute must return true if the <span>canceled flag</span> is set and
false otherwise.
<hr>
<p>The <dfn title=dom-Event-isTrusted><code>isTrusted</code></dfn> attribute
must return the value it was initialized to. When an
<span title=concept-event>event</span> is created the attribute must be
initialized to false.
<p>The <dfn title=dom-Event-timeStamp><code>timeStamp</code></dfn> attribute
must return the value it was initialized to. When an
<span title=concept-event>event</span> is created the attribute must be
initialized to the number of milliseconds that have passed since
00:00:00 UTC on 1 January 1970, ignoring leap seconds.
<!-- leap seconds are ignored by JavaScript too -->
<hr>
<p>To <dfn title=concept-event-initialize>initialize</dfn> an
<var title>event</var>, with <var title>type</var>,
<var title>bubbles</var>, and <var title>cancelable</var>, run these steps:
<ol>
<li><p>Set the <span>initialized flag</span>.
<li><p>Unset the <span>stop propagation flag</span>,
<span>stop immediate propagation flag</span>, and
<span>canceled flag</span>.
<li><p>Set the <code title=dom-Event-isTrusted>isTrusted</code> attribute
to false.
<li><p>Set the <code title=dom-Event-target>target</code> attribute to
null.
<li><p>Set the <code title=dom-Event-type>type</code> attribute to
<var title>type</var>.
<li><p>Set the <code title=dom-Event-bubbles>bubbles</code> attribute to
<var title>bubbles</var>.
<li><p>Set the <code title=dom-Event-cancelable>cancelable</code> attribute
to <var title>cancelable</var>.
</ol>
<p>The
<dfn title=dom-Event-initEvent><code>initEvent(<var title>type</var>, <var title>bubbles</var>, <var title>cancelable</var>)</code></dfn>
method, when invoked, must run these steps:
<ol>
<li><p>If <span>context object</span>'s <span>dispatch flag</span> is set, terminate
these steps.
<li><p><span title=concept-event-initialize>Initialize</span> the
<span>context object</span> with <var title>type</var>, <var title>bubbles</var>, and
<var title>cancelable</var>.
</ol>
<p class=note>As <span title=concept-event>events</span> have constructors
<code title=dom-Event-initEvent>initEvent()</code> is superfluous. However,
it has to be supported for legacy content.
<h3>Interface <code>CustomEvent</code></h3>
<pre class=idl>[<span title=concept-event-constructor>Constructor</span>(DOMString <var title>type</var>, optional <span>CustomEventInit</span> <var title>eventInitDict</var>),
Exposed=(Window,Worker)]
interface <dfn>CustomEvent</dfn> : <span>Event</span> {
readonly attribute any <span title=dom-CustomEvent-detail>detail</span>;
void <span title=dom-CustomEvent-initCustomEvent>initCustomEvent</span>(DOMString <var title>type</var>, boolean <var title>bubbles</var>, boolean <var title>cancelable</var>, any <var title>detail</var>);
};
dictionary <dfn>CustomEventInit</dfn> : <span>EventInit</span> {
any <span title=dom-CustomEventInit-detail>detail</span> = null;
};</pre>
<p><span title=concept-event>Events</span> using the
<code>CustomEvent</code> interface can be used to carry custom data.</p>
<dl class=domintro>
<dt><code><var title>event</var> = new <span title=concept-event-constructor>CustomEvent</span>(<var title>type</var> [, <var title>eventInitDict</var>])</code>
<dd><p>Works analogously to the constructor for <code>Event</code> except
that the optional <var title>eventInitDict</var> argument now
allows for setting the <code title=dom-Event-detail>detail</code> attribute
too.
<dt><code><var title>event</var> . <span title=dom-CustomEvent-detail>detail</span></code>
<dd><p>Returns any custom data <var title>event</var> was created with.
Typically used for synthetic events.
<!-- initCustomEvent is dead -->
</dl>
<p>The <dfn title=dom-CustomEvent-detail><code>detail</code></dfn> attribute
must return the value it was initialized to.
<p>The
<dfn title=dom-CustomEvent-initCustomEvent><code>initCustomEvent(<var title>type</var>, <var title>bubbles</var>, <var title>cancelable</var>, <var title>detail</var>)</code></dfn>
method must, when invoked, run these steps:
<ol>
<li><p>If <span>context object</span>'s <span>dispatch flag</span> is set, terminate
these steps.
<li><p><span title=concept-event-initialize>Initialize</span> the
<span>context object</span> with <var title>type</var>, <var title>bubbles</var>, and
<var title>cancelable</var>.
<li><p>Set <span>context object</span>'s <code title=dom-CustomEvent-detail>detail</code>
attribute to <var title>detail</var>.
</ol>
<h3>Constructing events</h3>
<p>When a <dfn title=concept-event-constructor>constructor</dfn> of the <code>Event</code>
interface, or of an interface that inherits from the <code>Event</code> interface, is
invoked, these steps must be run:
<ol>
<li><p>Create an <span title=concept-event>event</span> that uses the
interface the constructor was invoked upon.
<li><p>Set its <span>initialized flag</span>.
<li><p>Initialize the <code title=dom-Event-type>type</code> attribute to
the <var title>type</var> argument.
<li><p>If there is an <var title>eventInitDict</var> argument then for each
<span data-anolis-spec=webidl>dictionary member</span> defined therein find
the attribute on <span title=concept-event>event</span> whose
<span data-anolis-spec=webidl>identifier</span> matches the key of
the <span data-anolis-spec=webidl>dictionary member</span> and then
set the attribute to the value of that
<span data-anolis-spec=webidl>dictionary member</span>.
<li><p>Return the <span title=concept-event>event</span>.
</ol>
<h3>Defining event interfaces</h3>
<p>In general, when defining a new interface that inherits from
<code>Event</code> please always ask feedback from the WHATWG or the
W3C WebApps WG community.
<p>The <code>CustomEvent</code> interface can be used as starting point.
However, do not introduce any <code title>init<var>*</var>Event()</code>
methods as they are redundant with constructors. Interfaces that inherit
from the <code>Event</code> interface that have such a method only have it
for historical reasons.
<h3>Interface <code>EventTarget</code></h3>
<pre class=idl>[Exposed=(Window,Worker)]
interface <dfn>EventTarget</dfn> {
void <span title=dom-EventTarget-addEventListener>addEventListener</span>(DOMString <var title>type</var>, <span>EventListener</span>? <var title>callback</var>, optional boolean <var title>capture</var> = false);
void <span title=dom-EventTarget-removeEventListener>removeEventListener</span>(DOMString <var title>type</var>, <span>EventListener</span>? <var title>callback</var>, optional boolean <var title>capture</var> = false);
boolean <span title=dom-EventTarget-dispatchEvent>dispatchEvent</span>(<span>Event</span> <var title>event</var>);
};
callback interface <dfn>EventListener</dfn> {
void <span title=dom-EventListener-handleEvent>handleEvent</span>(<span>Event</span> <var title>event</var>);
};</pre>
<p><code>EventTarget</code> is an object to which an
<span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span> when something has
occurred. Each <code>EventTarget</code> has an associated list of
<span title=concept-event-listener>event listeners</span>.
<p>An <dfn title=concept-event-listener>event listener</dfn> associates a
callback with a specific <span title=concept-event>event</span>. Each
<span title=concept-event-listener>event listener</span> consists of a
<b>type</b> (of the <span title=concept-event>event</span>),
<b>callback</b>, and <b>capture</b> variable.
<p class=note>The <b>callback</b> is named <code>EventListener</code> for
historical reasons. As can be seen from the definition above, an
<span title=concept-event-listener>event listener</span> is a more broad
concept.
<dl class=domintro>
<dt><code><var title>target</var> . <span title=dom-EventTarget-addEventListener>addEventListener</span>(<var title>type</var>, <var title>callback</var> [, <var title>capture</var> = false])</code>
<dd>
<p>Appends an <span title=concept-event-listener>event listener</span>
for <span title=concept-event>events</span> whose
<code title=dom-Event-type>type</code> attribute value is
<var title>type</var>. The <var title>callback</var> argument sets the
<b>callback</b> that will be invoked when the
<span title=concept-event>event</span> is
<span title=concept-event-dispatch>dispatched</span>. When set to true,
the <var title>capture</var> argument prevents <b>callback</b> from being invoked when
the <span title=concept-event>event</span>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute value is
<code title=dom-Event-BUBBLING_PHASE>BUBBLING_PHASE</code>. When false, <b>callback</b>
will not be invoked when <span title=concept-event>event</span>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute value is
<code title=dom-Event-CAPTURING_PHASE>CAPTURING_PHASE</code>. Either way,
<b>callback</b> will be invoked when <span title=concept-event>event</span>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute value is
<code title=dom-Event-AT_TARGET>AT_TARGET</code>.
<p>The <span title=concept-event-listener>event listener</span> is
appended to <var title>target</var>'s list of
<span title=concept-event-listener>event listeners</span> and is not
appended if it is a duplicate (the
<span title=concept-event-listener>event listeners</span> in the list are
unique).
<dt><code><var title>target</var> . <span title=dom-EventTarget-removeEventListener>removeEventListener</span>(<var title>type</var>, <var title>callback</var> [, <var title>capture</var> = false])</code>
<dd><p>Remove the <span title=concept-event-listener>event listener</span>
in <var title>target</var>'s list of
<span title=concept-event-listener>event listeners</span> with the same
<var title>type</var>, <var title>callback</var>, and
<var title>capture</var>.
<dt><code><var title>target</var> . <span title=dom-EventTarget-dispatchEvent>dispatchEvent</span>(<var title>event</var>)</code>
<dd><p><span title=concept-event-dispatch>Dispatches</span> a synthetic
event <var title>event</var> to <var title>target</var> and returns true
if either <var title>event</var>'s
<code title=dom-Event-cancelable>cancelable</code> attribute value is false
or it's <code title=dom-Event-preventDefault>preventDefault()</code> method
was not invoked, and false otherwise.
</dl>
<p>The
<dfn title=dom-EventTarget-addEventListener><code>addEventListener(<var title>type</var>, <var title>callback</var>, <var title>capture</var>)</code></dfn>
method must run these steps:
<ol>
<li><p>If <var title>callback</var> is null, terminate these steps.
<li><p>Append an <span title=concept-event-listener>event listener</span>
to the associated list of
<span title=concept-event-listener>event listeners</span> with <b>type</b>
set to <var title>type</var>, <b>callback</b> set to <var title>callback</var>, and
<b>capture</b> set to <var title>capture</var>, unless there
already is an <span title=concept-event-listener>event listener</span> in
that list with the same <b>type</b>, <b>callback</b>, and <b>capture</b>.
</ol>
<p>The
<dfn title=dom-EventTarget-removeEventListener><code>removeEventListener(<var title>type</var>, <var title>callback</var>, <var title>capture</var>)</code></dfn>
method must run these steps:
<ol>
<li><p>Remove an <span title=concept-event-listener>event listener</span>
from the associated list of
<span title=concept-event-listener>event listeners</span>, whose
<b>type</b> is <var title>name</var>, <b>callback</b> is <var title>callback</var>, and
<b>capture</b> is <var title>capture</var>.</p>
</ol>
<p>The
<dfn title=dom-EventTarget-dispatchEvent><code>dispatchEvent(<var title>event</var>)</code></dfn>
method must run these steps:
<ol>
<li><p>If <var title>event</var>'s <span>dispatch flag</span> is set, or if
its <span>initialized flag</span> is not set,
<span title=concept-throw>throw</span> an
"<code>InvalidStateError</code>" exception.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-isTrusted>isTrusted</code> attribute to false.
<li><p><span title=concept-event-dispatch>Dispatch</span> the
<var title>event</var> and return the value that returns.
</ol>
<h3>Dispatching events</h3>
<p>To <dfn title=concept-event-dispatch>dispatch</dfn> an
<span title=concept-event>event</span> to a given object, optionally with
a <var title>target override</var>, run these steps:
<ol>
<li><p>Let <var title>event</var> be the
<span title=concept-event>event</span> that is dispatched.
<li><p>Set <var title>event</var>'s <span>dispatch flag</span>.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-target>target</code> attribute to
<var title>target override</var>, if it is given, or the object to which
<var title>event</var> is dispatched otherwise.
<li><p>If <var title>event</var>'s
<code title=dom-Event-target>target</code> attribute value is
<span title=concept-tree-participate>participating</span> in a
<span title=concept-tree>tree</span>, let <var title>event path</var> be a
static ordered list of all its
<span title=concept-tree-ancestor>ancestors</span> in
<span title=concept-tree-order>tree order</span>, and let
<var title>event path</var> be the empty list otherwise.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute to
<code title=dom-Event-CAPTURING_PHASE>CAPTURING_PHASE</code>.
<li><p>For each object in <var title>event path</var>,
<span title=concept-event-listener-invoke>invoke</span> its
<span title=concept-event-listener>event listeners</span> with event
<var title>event</var>, as long as <var title>event</var>'s
<span>stop propagation flag</span> is unset.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute to
<code title=dom-Event-AT_TARGET>AT_TARGET</code>.
<li><p><span title=concept-event-listener-invoke>Invoke</span> the
<span title=concept-event-listener>event listeners</span> of
<var title>event</var>'s <code title=dom-Event-target>target</code>
attribute value with <var title>event</var>, if <var title>event</var>'s
<span>stop propagation flag</span> is unset.
<li>
<p>If <var title>event</var>'s
<code title=dom-Event-bubbles>bubbles</code> attribute value is true, run
these substeps:
<ol>
<li><p>Reverse the order of <var title>event path</var>.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute to
<code title=dom-Event-BUBBLING_PHASE>BUBBLING_PHASE</code>.
<li><p>For each object in <var title>event path</var>,
<span title=concept-event-listener-invoke>invoke</span> its
<span title=concept-event-listener>event listeners</span>, with event
<var title>event</var> as long as <var title>event</var>'s
<span>stop propagation flag</span> is unset.
</ol>
<li><p>Unset <var title>event</var>'s <span>dispatch flag</span>.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-eventPhase>eventPhase</code> attribute to
<code title=dom-Event-NONE>NONE</code>.
<li><p>Initialize <var title>event</var>'s
<code title=dom-Event-currentTarget>currentTarget</code> attribute to null.
<li><p>Return false if <var title>event</var>'s <span>canceled flag</span>
is set, and true otherwise.
</ol>
<p>To <dfn title=concept-event-listener-invoke>invoke</dfn> the
<span title=concept-event-listener>event listeners</span> for an object with an
event run these steps:</p>
<ol>