/
506.txt
185 lines (150 loc) · 9.75 KB
/
506.txt
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
[10] [[DOMイベント]]は[[木構造]]に対して定義されていますが、
実際に[[木]]として使われるのは[[節点木]]
([CODE(DOMi)@en[[[Document]]]] や [CODE(DOMi)@en[[[Element]]]] の[[木]]) だけで、
それ以外のほとんどは単一の[[オブジェクト]]です。
* 仕様書
[REFS[
- [19] '''[CITE@en[DOM Standard]] ([TIME[2016-02-18 20:04:25 +09:00]] 版) <https://dom.spec.whatwg.org/#get-the-parent>'''
- [21] [CITE@en[DOM Standard]] ([TIME[2016-07-05 18:22:22 +09:00]]) <https://dom.spec.whatwg.org/#event-path>
- [46] [CITE@en[DOM Standard]] ([TIME[2016-07-05 18:22:22 +09:00]]) <https://dom.spec.whatwg.org/#dispatching-events>
- [22] [CITE@en[DOM Standard]] ([TIME[2016-02-18 20:04:25 +09:00]] 版) <https://dom.spec.whatwg.org/#node>
- [24] [CITE@en[DOM Standard]] ([TIME[2016-02-18 20:04:25 +09:00]] 版) <https://dom.spec.whatwg.org/#document>
- [39] [CITE@en[DOM Standard]] ([TIME[2016-07-05 18:22:22 +09:00]]) <https://dom.spec.whatwg.org/#concept-shadow-root>
]REFS]
* 親の取得
[16] [CODE(DOMi)@en[[[EventTarget]]]] は、
[[イベント]][VAR[イベント]]を[[引数]]とする[DFN[[RUBYB[親の取得]@en[get the parent]]]][[アルゴリズム]]を持ちます
[SRC[>>19]]。
[VAR[イベント対象]]の[[親の取得]]は、[VAR[イベント対象]]により、次のようにします。
[FIG(switch)[
: [[文書]] : [SRC[>>24]]
[FIG(steps)[
= [26] [VAR[イベント]]の[F[[[型]]]]が [CODE[[[load]]]] か、
[VAR[イベント対象]]の[F[閲覧文脈]]が [[null]] なら、
== [27] [[null]] を返します。
= [28] それ以外なら、
== [29] [VAR[イベント対象]]の[F[[CODE(DOMi)@en[[[Window]]]]]]を返します。
]FIG]
: [[影根]] : [SRC[>>39]]
[FIG(steps)[
= [40] [VAR[イベント]]の[F[合成フラグ]]が[[偽]]なら、
== [41] [[null]] を返します。
= [42] それ以外なら、
== [43] [VAR[イベント対象]]の[F[ホスト][影ホスト]]を返します。
]FIG]
: [[要素]]、[[テキスト]] : [SRC[>>22]]
[FIG(steps)[
= [34] [VAR[イベント対象]]が[F[割り当て済み]]なら、
== [35] [VAR[イベント対象]]の[F[割り当て済みスロット]]を返します。
= [36] それ以外なら、
== [37] [VAR[イベント対象]]の[F[親][parentNode]]を返します。
]FIG]
: [[文書型]]、[[注釈]]、[[処理指令]] :
[VAR[イベント対象]]の[F[親][parentNode]]を返します [SRC[>>22]]。
: それ以外 : [[null]] を返します [SRC[>>19]]。
]FIG]
[30] [[親の取得]]は、[[dispatch]] で参照されます。
* 木をまたぐイベントの伝播
[4] [[木]]構造を超えた[[イベント]]の伝播には次のものがあります。
[FIG(list)[
- [5] [CODE(DOMi)@en[[[Document]]]] -> [CODE(DOMi)@en[[[Window]]]] [SRC[>>8]]
- [38] [[割り当て済み節点]] -> [[スロット]]
- [7] [[影根]] -> [[影ホスト]]
- [6] [DEL[[CODE(HTMLe)@en[[[iframe]]]] [CODE(HTMLa)@en[[[seamless]]]] 境界 [SRC[>>11]]]]
-- [[子閲覧文脈]]の [CODE(DOMi)@en[[[Window]]]] の[[親]]が [CODE(DOMi)@en[[[iframe]]]]
]FIG]
* イベント経路
[23] [[イベントオブジェクト]]は、[DFN[[F[[RUBYB[経路]@en[path]]][イベント経路]]]]を持ちます [SRC[>>22]]。
[44] [[仕様書]]の規定は若干わかりにくい形になっています。次の説明は、少し違う
(が等価な) 形です。
[25] [F[経路][イベント経路]]の初期値は、空です [SRC[>>22]]。
[45] [F[経路][イベント経路]]は [[dispatch]] で設定されます。
[[dispatch]] 自体の他、 [CODE(DOMm)@en[composedPath]] でも参照されます。
[[仕様書]]上は[[影根]]の[F[親の取得]]でも参照されます。
[47] [F[経路][イベント経路]]は、 [[dispatch]] の最初で[VAR[イベント]]と[VAR[対象]]と[VAR[対象上書き]]を使って次のように構築されます [SRC[>>46]]。
[FIG(steps)[
= [52] [VAR[オブジェクト]]を、[VAR[対象]]に設定します。
= [58] [VAR[対象上書き]]が [[null]] なら、
== [50] [VAR[相対対象]]を、[VAR[対象]]に設定します。
= [59] それ以外なら、
== [60] [VAR[相対対象]]を、[VAR[対象上書き]]に設定します。
= [53] [VAR[イベント]]の[F[経路][イベント経路]]に、新しい項目を追加します。
[FIG(list members)[
: [F[現在対象]] : [VAR[オブジェクト]]
: [F[対象][イベント対象]] : [VAR[相対対象]]
: [F[関連対象]] :
[VAR[イベント]]の[F[関連対象]]が [CODE[null]] なら、 [CODE[null]]。それ以外なら、
[VAR[イベント]]の[F[関連対象]]を[VAR[オブジェクト]]について[[再対象付け]]した結果。
]FIG]
= [54] [VAR[親]]を、[VAR[オブジェクト]]の[F[親の取得]]を[VAR[イベント]]について実行した結果に設定します。
= [49] [VAR[親]]が [[null]] でなければ、
== [56] [VAR[オブジェクト]]と[VAR[親]]が違う[[木]]に属するなら、
=== [57] [VAR[相対対象]]を、[VAR[親]]に設定します。
== [55] [VAR[オブジェクト]]を、[VAR[親]]に設定します。
== [51] >>53 に戻ります。
]FIG]
[48] [F[イベント経路]]は、 [[dispatch]] の最後で空に戻されます [SRC[>>46]]。
[64] [VAR[節点]]を[VAR[基準点]]について[DFN[[RUBYB[再対象付け]@en[retarget]]]]した結果とは、
[VAR[節点]]と[VAR[基準点]]が同じ[[木]]に属するか、
[VAR[基準点]]が[[影木]]に属する (など[[影を含む子孫]]である) ならば[VAR[節点]]、
そうでないなら[VAR[節点]]の[F[根]]の[F[影ホスト]]を[VAR[基準点]]について[[再対象付け]]したものです [SRC[>>46]]。
@@
[66] [DFN[retargeting steps]] [SRC[>>46]]
* 歴史
[17] [[dispatch]] において [CODE(DOMi)@en[[[Window]]]] は [CODE(DOMi)@en[[[Document]]]]
の[[親]]として (ほとんどの場合に) 動作するよう昔から実装されていましたが、
[[HTML5]] まで明文化されていませんでした。
[REFS[
-[1] [CITE@en[Bug 18780 – Fix event dispatching for shadow DOM and <iframe seamless>]]
( ([TIME[2013-05-05 14:48:07 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=18780>
-[2] [CITE[IRC logs: freenode / #whatwg / 20121204]]
( ([TIME[2013-05-05 14:48:23 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20121204#l-1477>
- [11] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2015-05-06 10:42:35 +09:00]] 版) <https://html.spec.whatwg.org/#attr-iframe-seamless>
- [8] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2013-05-05 06:42:10 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#events-and-the-window-object>
]REFS]
[18] [[DOM Standard]] によって[[イベント]]の仕様が再整備されたことで、
[[HTML Standard]] もそれに基づく規定に切り替えられました。
[3] >>1 により [[HTML Standard]] は [[DOM Standard]] より [[event parent]] と
[[cross-boundary event parent]] を引用していますが、現時点で [[DOM Standard]]
に両者の定義はありません。 [TIME[2013-05-05T14:50:19.700Z]]
[HISTORY[
[9] [[閲覧文脈]]中にある [CODE(DOMi)@en[[[Document]]]] に属する[[節点]]において[[イベント]]が[[ディスパッチ]]される時、
[[イベント型]]が [CODE(DOMe)@en[[[load]]]] である時を除き、
[CODE(DOMi)@en[[[Window]]]] が [CODE(DOMi)@en[[[Document]]]] の[[親]]であるように振舞わなければ[['''なりません''']]
[SRC[>>8]]。
]HISTORY]
[13] [CODE(HTMLa)@en[[[seamless]]]] は実装されなかったため2016年2月に削除されました。
[REFS[
- [12] [CITE@en[Remove <iframe seamless> · whatwg/html@1490eba]]
([TIME[2016-02-04 19:17:43 +09:00]] 版)
<https://github.com/whatwg/html/commit/1490eba4dba5ab476f0981443a86c01acae01311>
]REFS]
[20] 2016年2月には[[イベント親]]は[[親の取得]]という形に再編されて、
[[DOM Standard]] に規定が集約されました。
[REFS[
- [14] [CITE@en[Integrate HTML's monkey patch to the event path · whatwg/dom@2d7b637]] ([TIME[2016-02-19 18:05:29 +09:00]] 版) <https://github.com/whatwg/dom/commit/2d7b637b31fc6bad8f6c4743fb61016392fac382>
- [15] [CITE@en[Remove event path monkey patch · whatwg/html@dad854e]] ([TIME[2016-02-19 18:05:36 +09:00]] 版) <https://github.com/whatwg/html/commit/dad854e4c1f5f7098a1b1ec7f33e2218796f7442>
]REFS]
[31] [CITE@en[''''''[''''''Fix #429'''''']'''''' Integrate "get the parent" model for an event path · w3c/webcomponents@0457494]]
([TIME[2016-03-11 15:38:08 +09:00]] 版)
<https://github.com/w3c/webcomponents/commit/0457494032c6668291319df843a7a62faca214c5>
[32] [CITE@en[Fix #486: Fix 'get the parent' for relatedTarget]]
( ([[hayatoito]]著, [TIME[2016-06-01 14:53:00 +09:00]]))
<https://github.com/w3c/webcomponents/commit/b1433e5f3a013ca825f02fb8f7b0e9d6217c0125>
[33] [CITE@en['''['''''']''' (0) Make the Window object support events]]
( ([[Hixie]]著, [TIME[2007-04-21 11:41:48 +09:00]]))
<https://github.com/whatwg/html/commit/16d81185f31b98ef752e036fce228199a1e8502c>
[61] [CITE@en[Shadow: define event retargeting for shadow trees]]
([[annevk]]著, [TIME[2016-04-29 21:04:07 +09:00]])
<https://github.com/whatwg/dom/commit/ed94c9f2f1850b2e6a9b357c6870186859da4c2d>
[62] [CITE@en[Shadow: define Event's composedPath()]]
([[annevk]]著, [TIME[2016-05-12 18:40:32 +09:00]])
<https://github.com/whatwg/dom/commit/58b19e4aa89ab0c6ef998daa455dcbb189423cf8>
[63] [CITE@en[Shadow: define event's relatedTarget handling]]
([[hayatoito]]著, [TIME[2016-07-22 16:39:19 +09:00]])
<https://github.com/whatwg/dom/commit/ef69a247681532e6102ced9a78aabf7f7a536108>
[65] [CITE@en[Shadow: add "retargeting steps" to the dispatch algorithm]]
([[hayatoito]]著, [TIME[2016-08-04 18:36:08 +09:00]])
<https://github.com/whatwg/dom/commit/fbc0c312c3ead6940718e3d2d7511f2b014011e1>