/
531.txt
178 lines (140 loc) · 6.32 KB
/
531.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
* [CODE(HTMLa)@en[autofocus]] 属性 (HTML、HTML DOM)
[1] [[HTML]] の[[フォーム制御子]]の
[DFN[[CODE(HTMLa)@en[autofocus]] [[属性]]]]は、
[[焦点]]を自動的にその[[制御子]]に与えるべきことを示します。
[3] [[内容属性]]
:状態:[[WHATWG]] [[WD]]
:[[要素型]]:[[フォーム制御子]]
:[CODE(DOMa)@en[[[type]]]]:[CODE(HTML)@en[[[hidden]]]]
と [CODE(HTMLe)@en[[QN[[[output]]][http://www.w3.org/1999/xhtml]]]]
を''除く''
:[[属性名]]:[CODE(HTMLa)@en[[[autofocus]]]]
:[[属性値]]:[[ブール型属性]] (>>4)
:[[既定値]]:[[偽]] (>>5)
[9] [[DOM属性]]
:状態:[[WHATWG]] [[WD]]
:[[界面]]:[CODE(DOMi)@en[[[HTMLInputElement]]]],
[CODE(DOMi)@en[[[HTMLTextAreaElement]]]],
[CODE(DOMi)@en[[[HTMLSelectElement]]]],
[CODE(DOMi)@en[[[HTMLButtonElement]]]]
:[[属性名]]:[CODE(DOMa)@en[[[autofocus]]]]
:[[型]]:[CODE(IDL)@en[[[boolean]]]]
[2] 仕様書:
- [[Web Forms 2.0]]
-- [CSECTION@en[2.10. The [CODE(HTMLa)@en[[[autofocus]]]] attribute]]
<IW:WF2:"#the-autofocus">
** 内容属性値
[4]
[[属性値]]を設定する場合は、
[CODE(DOM)@en[[[autofocus]]]] と[['''するべきです''']]。
[SRC@en[WF2 2.10]]
[5]
[[#comment]]
** DOM 属性値
[10] '''取得'''
[[DOM属性]] [CODE(DOMa)@en[[[autofocus]]]]
は、[[内容属性]] [CODE(HTMLa)@en[[[autofocus]]]]
が存在していれば、[[属性値]]に関わらず、
[CODE(IDL)@en[[[true]]]] が返される値と[['''しなければなりません''']]。
[[内容属性]]が存在しない場合は
[CODE(IDL)@en[[[false]]]] と[['''しなければなりません''']]。
[SRC@en[WF2 2.10]]
[11] '''設定'''
[[DOM属性]] [CODE(DOMa)@en[[[autofocus]]]]
は、[CODE(IDL)@en[[[true]]]] と設定された時には、
[[内容属性]] [CODE(HTMLa)@en[[[autofocus]]]]
の[[属性値]]は [CODE(HTML)@en[[[autofocus]]]]
と設定[['''しなければなりません''']]。
[CODE(IDL)@en[[[false]]]] と設定された時には、
[[内容属性]] [CODE(HTMLa)@en[[[autofocus]]]]
は削除[['''しなければなりません''']]。
[SRC@en[WF2 2.10]]
[[#comment]]
** HTML 直列化
[13]
([[XHTML]] ではない) [[HTML]] では、
[PRE(HTML example code)[
<input autofocus="autofocus">
]PRE]
と同じ意味で、
[PRE(HTML example code)[
<input autofocus>
]PRE]
と省略することができます。
[SRC@en[WF2 2.10]]
[[#comment]]
** レンダリング
[6]
[[利用者エージェント]]は、
[[フォーム制御子]]が[[文書]]に[[挿入]]された時、
[CODE(HTMLa)@en[[[autofocus]]]] [[属性]]が設定されているかどうかを確認[['''しなければなりません''']]。
[[利用者エージェント]]は、
[CODE(HTMLa)@en[[[autofocus]]]] [[属性]]が設定されており、
[CODE(HTMLa)@en[[[disabled]]]]
では''なく''、その[[環境]]で通常[[焦点]]を当てることができる種類のものであれば、
その[[制御子]]の [CODE(DOMm)@en[[[focus]]]]
[[メソッド]]が呼ばれた場合と同じように[[焦点]]を授与[['''するべきです''']]。
[[閲覧領域]]を持つ[[利用者エージェント]]は、
[[焦点]]を当てることが可能かどうかに関わらず、
その[[フォーム制御子]]が可視になるように[[文書]]を[[スクロール]][['''するべきです''']]。
[SRC@en[WF2 2.10]]
[8]
[[利用者エージェント]]は、
[[利用者]]が[[焦点]]を移して欲しくない場合にこの[[属性]]を無視[['''して構いません''']]。
例えば、[[利用者]]が入力を開始したら、
それ以後 [CODE(HTMLa)@en[[[autofocus]]]]
は無視して構いません。
[SRC@en[WF2 2.10]]
[14]
[[Webブラウザ]]の[[窓]]が[[焦点]]を失っている時に
[CODE(HTMLa)@en[[[autofocus]]]]
が指定されていても、
[[窓]]が[[焦点]]を得なければならないわけではありません。
[SRC@en[WF2 2.10]]
[20] [[履歴]]の移動で [[bfcache]] から復元した際は、 [CODE(HTMLa)@en[[[autofocus]]]]
ではなく、以前の表示の際の[[フォーカス]]を復元するべきと思われます。
** 誤り処理
[7]
[[著者]]は、複数の有効な[[要素]]に
[CODE(HTMLa)@en[[[autofocus]]]] [[属性]]を設定[['''してはなりません''']]。
複数の要素が [CODE(HTMLa)@en[[[autofocus]]]]
な場合、順に >>6 のように処理されるので、
[[文書]]の読込み直後には[[文書順]]で最後の[[焦点]]を当てられる[[フォーム制御子]]が[[焦点]]を得ることになります。
[SRC@en[WF2 2.10]]
[[#comment]]
** 例
[12]
[PRE(HTML example code)[
<input maxlength="256" name="q" value="" autofocus="autofocus">
<input type="submit" value="Search">
]PRE]
この例では、[[文書]]が読込まれると、
[[テキスト欄]]に[[焦点]]が当てられます。
[[#comment]]
** メモ
[[#comment]]
* メモ
[15] [CITE@en[HTML5 Revision Tracker]]
([TIME[2010-07-30 07:56:25 +09:00]] 版)
<http://html5.org/tools/web-apps-tracker?from=5221&to=5222>
[16] [CITE['''['''whatwg''']''' Two propositions for the autofocus attribute]]
([TIME[2010-08-25 09:09:30 +09:00]] 版)
<http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2010-August/028124.html>
[17] [CITE[''''''[''''''whatwg'''''']'''''' Autofocus readonly Input Elements]]
( ([TIME[2011-09-24 09:56:48 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-September/033284.html>
[18] [CITE@en[Web Applications 1.0 r8152 Make autofocus='' not force the 'load' event to be delayed by style computation.]]
( ([TIME[2013-08-22 14:23:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=8151&to=8152>
[19] [CITE[IRC logs: freenode / #whatwg / 20130822]]
( ([TIME[2013-08-26 10:03:00 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20130822>
[21] [CITE@en[Queue a task to run all the autofocusing steps]]
([[domenic]]著, [TIME[2018-03-07 14:32:39 +09:00]])
<https://github.com/whatwg/html/commit/185190cac859144cfcd78248b906f3adae1f0594>
[22] [CITE@en[Autofocus has weird racy behavior · Issue #3467 · whatwg/html]]
([TIME[2018-03-08 15:24:37 +09:00]])
<https://github.com/whatwg/html/issues/3467>
[23] [CITE@en[Queue a task to run all the autofocusing steps by domenic · Pull Request #3488 · whatwg/html]]
([TIME[2018-03-08 15:26:31 +09:00]])
<https://github.com/whatwg/html/pull/3488>