
[1] [DFN[[RUBYB[イベント型] [Event type]]]]は、[[DOMイベント]]の種類です。
[[イベント]]の[DFN[[RUBYB[[[名前]]]@en[name]]]]とも呼ばれます [SRC[>>22]]。

* 仕様書

[REFS[
- [20] '''[CITE@en-US[DOM Standard]] ([TIME[2013-04-26 20:00:45 +09:00]] 版) <http://dom.spec.whatwg.org/#dom-event-type>'''
- [32] [CITE@en[DOM Standard]] ([TIME[2016-02-20 20:19:45 +09:00]] 版) <https://dom.spec.whatwg.org/#concept-event-listener-invoke>
- [22] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-04-30 04:07:36 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#dependencies>
]REFS]

* 構成

[18] 
[[DOM 2]] と [[XML事象]]では、事象型は [[XML 1.0]] の [CODE(ABNF)[[[Name]]]]
によって表されます。 [[DOM 3]] では、事象型は[[名前空間URI]]
と[[局所名]]によって表され、 XML 事象の [CODE(XMLa)[[[event]]]]
属性に [CODE(char)[:]] が含まれているときは[[修飾名]]と解釈することを勧めています。

[2] DOM 2 および DOM 3 では、様々な事象が定義されています。

* [CODE(DOMa)@en[type]] 属性

[19] [CODE(DOMi)@en[[[Event]]]] [[オブジェクト]]の [DFN[[CODE(DOMa)@en[[[type]]]]]]
[[属性]]は、当該[[イベント]]の[[イベント型]]を返します。 [SRC[>>20]]

[21] [[イベント]]の作成直後は[[空文字列]]となります [SRC[>>20]]。
[[初期化]]された際に値が割り当てられます。

[38] [[著者]]は[[イベント型]]を後から変更することができません。

[39] [[利用者エージェント]]は [[dispatch]] 中に[[遺物イベント型]]を処理しなければならない場合に限り、
[[イベント型]]を一時的に変更することがあります。

* 特別なイベント型

** dispatch の特殊動作

[40] [[dispatch]] における特別な扱いについては[[イベント親]]を参照。

** イベントハンドラーの特殊動作

[33] [[イベントハンドラー]]参照。

** 遺物イベント型

[31] 次の[[イベント型]]には、対応する[DFN[[RUBYB[遺物イベント型]@en[legacy event type]]]]が規定されています
[SRC[>>32]]。これは[[dispatch]]で特別扱いされます。

[FIG(table)[
:t: [[イベント型]]
:l: [[遺物イベント型]]

:t: [CODE[[[animationend]]]]
:l: [CODE[[[webkitAnimationEnd]]]]

:t: [CODE[[[animationiteration]]]]
:l: [CODE[[[webkitAnimationIteration]]]]

:t: [CODE[[[animationstart]]]]
:l: [CODE[[[webkitAnimationStart]]]]

:t: [CODE[[[transitionend]]]]
:l: [CODE[[[webkitTransitionEnd]]]]
]FIG]

;; [37] >>35 に [[JSON]] 形式の一覧データファイルがあります。
[REFS[
- [35] [CITE@en[data-web-defs/dom-events.json at master · manakai/data-web-defs]] ([TIME[2016-02-21 16:48:18 +09:00]] 版) <https://github.com/manakai/data-web-defs/blob/master/data/dom-events.json>
-- [36] ドキュメント [CITE@en[data-web-defs/dom-events.txt at master · manakai/data-web-defs]] ([TIME[2016-02-21 16:48:48 +09:00]] 版) <https://github.com/manakai/data-web-defs/blob/master/doc/dom-events.txt>
]REFS]

* イベント型の一覧

[28] [[DOMイベントの一覧]]参照。

* 名前空間

[4] DOM 水準 2 では事象名は一つの名前でしたが、 DOM 水準 3
では名前空間と局所名の組として再定義されています。
このため、 DOM 水準 3 では [Q[NS]] 系メソッドが追加されたとか、
互換性のための特別な措置が規定されています。

- DOM 水準 2 の事象は、名前空間 [CODE(DOM)[[[null]]]] とします。
- 名前空間 [CODE(DOM)[null]] の事象が発生した時には、
実行する[[事象聴取器]]の選択には、局所名のみを使います。
- 名前空間ありの事象が発生した時には、
事象聴取器の選択の際に、名前空間 [CODE(DOM)[null]]
の事象聴取器は局所名だけを比較します。
- [CODE(DOMm)[[[removeEventListener]]]] は、
局所名だけで削除する事象聴取器を選んでも構いません。
名前空間付きの事象聴取器がすべて削除されてしまうか、
どれも削除されないかは実装依存です。
問題が起こらないように [CODE(DOMm)[[[removeEventListenerNS]]]]
を使うべきです。

この措置により、多くの場合には名前空間の有無に関わらず意図した通りに動作するでしょうが、
名前空間を使うメソッドと使わないメソッドの混用は不要な混乱を招く虞がありますから、
好ましくありません。
常に名前空間付きのメソッドを使うのが好ましいでしょう。

[10]
>>4 のように 2003年の [[DOM WG]] の[[DOM水準3]] [[事象]][[モジュール]]の [[Note]] には書かれていましたが、その後
[[Web API WG]] によりこの部分は改訂されています。
[[名前空間]]非対応の[[メソッド]]は[[名前空間]]対応の[[メソッド]]で[[名前空間]]として
[CODE(DOM)@en[[[null]]]] を指定したのと同じことになります。
そのように明確に定義されたことにより、両者の混用は望ましくないとする注記も削除されています。

* インターフェイス

[25] [[イベント]]オブジェクトは、 [CODE(DOMi)@en[[[Event]]]]
[[インターフェイス]]か、それを[[継承]]した[[インターフェイス]]を使います。

[26] [[利用者エージェント]]が[[発火]]させる[[イベント]]に関しては、
[[イベント型]]と文脈によって自動的に[[イベント]]インターフェイスが決まります。
ほとんどの[[イベント型]]は、特定の[[イベント]]インターフェイスしか使いません。

[27] [[著者]]は、[[イベント]]オブジェクトと[[イベント型]]の組み合わせを任意に決めることができます。

* 歴史

** W3C DOM

[11]
[[DOM水準2]] [[事象]]では、[[事象型]]は1つの[[名前]]により[[識別]]されるとされていました。この[[名前]]は [[XML 1.0]]
の [CODE(XML)@en[[[Name]]]] でなければならないとされていました。
また、[[大文字]]・[[小文字]]を区別しないとされていました。
更に、 [CODE(DOMe)@en[[[DOM]]]] で始まる[[名前]]は将来の
[[DOM]] の[[事象]]のために[[予約]]されていました。
加えて、第3者が[[事象]]を追加する場合には[[名前]]の衝突を防ぐための[[接頭辞]]をつけることが強く[[推奨]]されていました。
([[名無しさん]])

[12]
2003年の[[DOM WG]] [[Note]] の[[DOM水準3]] [[事象]]では、
[[事象型]]は[[名前空間URI]]と[[局所名]]の組により[[識別]]されるとされていました。
[[局所名]]は [[XML名前空間 1.0]] の [CODE(XML)@en[[[NCName]]]]
であるべきだとされていました。[[大文字]]・[[小文字]]は区別するようになっており、
[[接頭辞]]に関する言及もなくなっていました。
([[名無しさん]])

[13]
[[Web API WG]] の [[DOM水準3]] [[事象]]によれば、
[[事象型]]は[[名前空間URI]]と[[局所名]]の組により[[識別]]されます。
ただし、どの[[名前空間]]にも属さない ([[null名前空間]]に属する)
こともあります。[[局所名]]は [[XML名前空間 1.1]]
の [CODE(XML)@en[[[NCName]]]] でなければならないとされています。
[[大文字]]・[[小文字]]は区別します。

[16] [[Firefox]] [[bfcache]]
-[[pageshow]]
-[[pagehide]]

[17] [CITE@EN[XForms 1.1]]
([TIME[2009-10-20 22:51:54 +09:00]] 版)
<http://www.w3.org/TR/2009/REC-xforms-20091020/#rpm>

** HTML5

[41] [CITE@en[Web Applications 1.0 r7099 Move slightly more towards using the word 'type' rather than 'name' for the concept of an event name]]
( ([TIME[2012-05-09 04:51:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7098&to=7099>

[23] [CITE@en[Web Applications 1.0 r8385 Add an event index which acts as the definition of the event names, for editorial purposes (event names are really just strings, so they don't have, or need, a normative definition per se).]]
( ([TIME[2014-01-09 08:55:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8384&to=8385>

[24] [CITE[IRC logs: freenode / #whatwg / 20140108]]
( ([TIME[2014-01-09 22:07:16 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20140108>

[FIG(quote)[
[FIGCAPTION[
[29] [CITE@en-US[Document Object Model Events]]
([TIME[2003-11-06 11:10:02 +09:00]] 版)
<http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-EventTypes-category>
]FIGCAPTION]

> An event type could be part of one or more categories. A category is represented using a local name and a namespace URI as defined in '''['''XML Namespaces''']'''. The event types defined in this specification are not associated with one or more event categories and this specification does not provide methods to associate them. Other specifications may create and associate event categories with event listeners but in such case would need to inform the dispatch mechanism of those event categories. An example of the use of categories is given at Using VoiceXML Events.

]FIG]


[FIG(quote)[
[FIGCAPTION[
[30] [CITE@en-US[Document Object Model Events]]
([TIME[2003-11-06 11:10:02 +09:00]] 版)
<http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#Events-registration-voicexmlevents-h3>
]FIGCAPTION]

> Event listeners can only be registered on Element nodes, i.e. other Node types are not addressable, and cannot be registered for a specific group either, i.e. they are always attached to the default group. The target phase and the bubbling phase are coupled during the registration. '''['''VoiceXML 2.0''']''' does not address namespaces in event types but uses the notion of event categories. The event type "connection.disconnect.hangup" could be associated to the event categories {"http://www.example.org/2003/voicexml", "connection"} and {"http://www.example.org/2003/voicexml", "connection.disconnect"}.

]FIG]

[34] [CITE@en[Fix #156: add legacy event type check to invoke algorithm · whatwg/dom@a026ccf]]
([TIME[2016-02-21 16:26:53 +09:00]] 版)
<https://github.com/whatwg/dom/commit/a026ccf3efa8d34fb0cac580928f61d18b1e9f76>