-
Notifications
You must be signed in to change notification settings - Fork 4
/
718.txt
249 lines (191 loc) · 11.5 KB
/
718.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
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
* 仕様書
[REFS[
- [11] [CITE@en[DOM Standard]] ([TIME[2016-02-20 20:19:45 +09:00]] 版) <https://dom.spec.whatwg.org/#element>
- [39] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2016-05-14 09:55:50 +09:00]]) <https://html.spec.whatwg.org/#semantics-2>
]REFS]
* 意味
[40] [[著者]]は、[[属性]]や[[属性値]]を、その想定用途以外の目的で使っては[MUST[なりません]]
[SRC[>>39]]。これは、[[文書]]を正しく処理できるようにするための要件です [SRC[>>39]]。
* 文脈
[38] [[著者]]は、[[属性]]や[[属性値]]を、[[適用可能な仕様書]]で認められていないのに使っては[MUST[なりません]] [SRC[>>39]]。
これは、[[言語]]の将来の拡張の余地を残すためです [SRC[>>39]]。
[42] どのような[[属性]]を使って良いかは、[[要素]]ごとに決められています。
;; 各[[要素]]の項を参照。
[43] いくつかの[[属性]]は、多数の[[要素]]で共通して使うことができます。
そうした[[属性]]を、次のように分類しています。
[FIG(short list)[
- [[超大域属性]]
- [[大域属性]]
[HISTORY[
- [[共通属性]]
]HISTORY]
]FIG]
[44] なお、同じ[[属性名]]であっても、[[要素]]によって異なる意味を持つことがあります。
[45] ほとんどの[[要素]]は、特定の[[属性]]のみを認め、それ以外を禁止しています。
例外的に、次の[[要素]]は、 (一定の制約の元で) [[著者]]が任意の[[名前][属性名]]の[[属性]]を使うことを認めています。
[FIG(short list)[
- [CODE(HTMLe)@en[embed]]
- [[自律カスタム要素]]
]FIG]
この他に、 [CODE(HTMLa)@en[data-[VAR[*]]]] [[属性]]を多くの[[要素]]で使えます。
* [CODE(DOMi)@en[Attr]] インターフェイス (DOM)
[13] [[DOM1]] で[RUBYB[属性節] [[CODE(DOM)[Attr]] node]]が持つことが出来る子[[節]]の種類は、
[[Text]] と [[EntityReference]] の2種類です。
[14] [[DOM]] の文書木・節モデルの中では、[[属性]]はやや特殊な位置づけになっています。
- [CODE(DOM)[Attr]] 節は、文書木の中には現れません。
- 親節・兄弟節はありません。 (取出す method の結果は [CODE(DOM)[null]]。)
- [[DTD]] で既定値が宣言されている場合には、その要素の属性値が明示されていない場合に常にその既定値が設定されていることとなります。
- [CODE(DOM)[[[DocumentFragment]]]] 節の直接の子要素にはできません。
- [CODE(DOMattr)[[[nodeValue]]]] では属性値文字列が、 [CODE(DOMa)[[[childNodes]]]] では [CODE(DOM)[[[Text]]]] 節及び [CODE(DOM)[[[EntityReference]]]] 節の組合せによる属性値の表現が得られます。
[15] [CODE(DOMi)[[[Node]]]] を継承して、
,読取専用属性 ,[CODE(DOMa)[[[name]]]] ,名前 ,[DOM1]
,読取専用属性 ,[CODE(DOMa)[[[specified]]]] ,指定されているか ,[DOM1]
,属性 ,[CODE(DOMa)[[[value]]]] ,値 ,[DOM1]
,読取専用属性 ,[CODE(DOMa)[[[ownerElement]]]] ,親要素節 ,[DOM2]
- [DOM1] ''Document Object Model (Core) Level 1'' <http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-637646024>
- [DOM2] ''Document Object Model Core'' <http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-637646024>
- [4] 親節になれるのは [CODE(DOM)[[[Element]]]] 節だけです。
- [5] DOM 1 は、属性の型は分からないかもしれないから字句化値を扱う機能は提供しないといっています。ですから、例えば [CODE(XML)[IDREFS]] 型属性値の3番目の [CODE(XML)[ID]] を取り出したい、という場合には、属性値全体を受け取ってそれを勝手に解析する必要があります。
[16] [CODE(DOMi)[Attr]] 節点の子孫である [CODE(DOMi)[[[EntityReference]]]] 節点の子供は
[CODE(DOMi)[[[EntityReference]]]] または
[CODE(DOMi)[[[Text]]]] しか認められない・・・はずですが、
[[DOM]] の仕様書にはそんなこと一言も書いてないな。
[17] [[DOM]] の仕様書には [CODE(DOMi)@en[[[Attr]]]]
は他の種類の [CODE(DOMi)@en[[[Node]]]] とは違って
[CODE(DOMi)@en[[[Element]]]] と切り離せないものだとかなんとか説明がありますが、
それでいてなぜか [CODE(DOMi)@en[[[Attr]]]]
が単独で存在できたりします。
それ自体は値を持たずに[[子孫]]がいたり。
[18]
[PRE[
Interface AttrExtended
IDL Definition
attribute boolean type;
Attributes
isClassAttribute of type boolean
Whether the attribute is a class attribute or not.
If it is a class attribute, the value is "true"; otherwise, "false".
Note that not all attributes whose local name is "class"
is a class attribute.
]PRE]
[19] [[Chrome]] は [[DOM3]] の規定通り [CODE(DOMi)@en[[[Attr]]]] の[[子供]]に [CODE(DOMi)@en[[[Text]]]]
が来る構造になっていて、通常の [CODE(DOMi)@en[[[Node]]]] として操作できます。
しかし [[WinIE]] や [[Gecko]] は [[DOM4]] の規定のように [CODE(DOMi)@en[[[Attr]]]]
の値を[[節点]]としては扱っていません。 [CODE(DOMa)@en[[[childNodes]]]] は空ですし、
[CODE(DOMm)@en[[[appendChild]]]] は [CODE(DOMe)@en[[[HierarchyRequestError]]]] になります。
[TIME[2012-12-15T13:41:44.200Z]]
[20] [CITE[IRC logs: freenode / #whatwg / 20121213]]
( ([TIME[2012-12-17 21:09:20 +09:00]] 版))
<http://krijnhoetmer.nl/irc-logs/whatwg/20121213#l-339>
[21] [CITE@en[Re: ''''''[''''''DOMCore'''''']'''''' Attr]]
( ([[Jonas Sicking]] 著, [TIME[2010-09-11 01:28:14 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webapps/2010JulSep/0797.html>
[22] [CITE@en-US[Attr - Document Object Model (DOM) | MDN]]
( ([TIME[2012-09-30 03:37:57 +09:00]] 版))
<https://developer.mozilla.org/en/docs/DOM/Attr>
* 属性 (SGML)
[1]
>
:(141) (要素の) 属性 [attribute (of an element)]:
[[型]]及び[[内容]]を除く[[特質]]。 [SRC[[[JIS X 4151]]‐1992 3.]]
[2] [[SGML]] では[[要素型]]や[[要素]]の[[内容]]も広い意味では[Q[属性]]に含まれます
[SRC[JIS X 4151‐1992 参考]]。 [[SGML]] [[規格本体]]で特に
[Q[要素の属性]]として定義されているものはそれ以外、
すなわち[[属性指定]]で指定され得る形式的な属性のみを指すべく >>1
のように説明されています。
* 属性 (XML)
[3]
>
:[RUBYB[属性] [attribute]]:
属性は [[DTD]] で宣言される[[要素]]の[[引数]]です。
[[属性]]の[[型]]と[[値域]]、更に場合によっては[[既定値]]は
[[DTD]] で定義されます。
仕様書:
- [[XHTML 1.0]]
-- [CITE[2.2. General Terms]]
<IW:XHTML10:"general">
[7] [CITE[IRC logs: freenode / #whatwg / 20090925]]
([TIME[2009-11-17 00:09:05 +09:00]] 版)
<http://krijnhoetmer.nl/irc-logs/whatwg/20090925#l-298>
* 属性節点 (XPath 1.0 データモデル) / [CODE[attribute::]] ([CODE[@]]) 軸 (XPath 1.0)
@@ XXX
[30] [[Chrome]] でも [[Firefox]] でも、仕様通り [CODE(XML)@en[[[xmlns]]]] [[名前空間]]の[[属性]]は
[[XPath]] データモデル上の[[属性節点]]としては存在しません。 [TIME[2013-10-05T08:24:31.300Z]]
* 属性情報項目 (XML 情報項目)
[6]
[[Atom]] や [[AtomPub]] の仕様書では、「[[属性]]」は[[属性情報項目]]を意味します。
;;[CITE@en[RFC 5023 - The Atom Publishing Protocol]] ([TIME[2008-11-20 18:52:14 +09:00]] 版) <http://tools.ietf.org/html/rfc5023#section-2.1.1>
* 属性の変化
[36] [[要素]]の[[属性]]が変化した時の[[要素]]・[[属性]]依存の動作を記述するためのフックが
[[DOM Standard]] で[DFN[[RUBYB[属性変更手順群]@en[attribute change steps]]]]として定義されています。 [SRC[>>11]]。
[HISTORY[
[23] [[要素]]の[[属性]]が変化した時の[[要素]]・[[属性]]依存の動作を記述するためのフックが
[[DOM Standard]] で4つ定義されています [SRC[>>11]]。
[FIG(list)[
- [24] [DFN[[RUBYB[[[属性の設定]]]@en[attribute is set]]]]
-- [[要素]]に関連付けられた [CODE(DOMi)@en[[[DOMTokenList]]]] との同期 [SRC[[[DOM Standard]]]]
- [25] [DFN[[RUBYB[[[属性の追加]]]@en[attribute is added]]]]
- [26] [DFN[[RUBYB[[[属性の変更]]]@en[attribute is changed]]]]
- [27] [DFN[[RUBYB[[[属性の削除]]]@en[attribute is removed]]]]
-- [[要素]]に関連付けられた [CODE(DOMi)@en[[[DOMTokenList]]]] との同期 [SRC[[[DOM Standard]]]]
]FIG]
[28] 設定は追加・変更のどちらかと同時に起こります。
]HISTORY]
[37] 次のものに[[属性変更手順群]]が定義されています。
[FIG(short list)[
- [CODE(DOMi)@en[DOMTokenList]]
- [CODE(HTMLe)@en[slot]]
- [[スロット可能]]
]FIG]
[29] [[HTML Standard]] はこのフックを使っていませんが、[[属性]]が変化した時に次のような処理が連動して行われます。
[FIG(list middle)[
- [CODE(HTMLe)@en[[[base]]]] [CODE(HTMLa)@en[[[href]]]] - [[凍結基底URLを設定]]
- [CODE(HTMLe)@en[[[iframe]]]]
- [CODE(HTMLe)@en[[[iframe]]]] [CODE(HTMLa)@en[[[name]]]]
- [CODE(HTMLe)@en[[[iframe]]]] [CODE(HTMLa)@en[[[sandbox]]]]
- [CODE(HTMLe)@en[[[iframe]]]] [CODE(HTMLa)@en[[[allowfullscreen]]]]
- [CODE(HTMLe)@en[[[frame]]]] [CODE(HTMLa)@en[[[name]]]]
- [CODE(HTMLe)@en[[[embed]]]]
- [CODE(HTMLe)@en[[[object]]]]
- [CODE(HTMLe)@en[[[param]]]]
- [CODE(HTMLa)@en[[[accesskey]]]]
- [CODE(HTMLe)@en[[[<script async>]]]]
- [CODE(HTMLe)@en[[[<script src>]]]]
]FIG]
[HISTORY[
[8] かつては次の[[内容属性]]にも処理が規定されていました。
[FIG(short list)[
- [CODE(XMLa)@en[[[xml:base]]]]
]FIG]
]HISTORY]
[41] [[レンダリングの更新]]も参照。
* 歴史
[31] [CITE@en[Touch Events]]
( ([TIME[2013-10-12 10:35:42 +09:00]] 版))
<https://dvcs.w3.org/hg/webevents/raw-file/v1/touchevents.html#webidl-conform>
[32] [CITE@en[Re: Moving Touch Events v1 to Recommendation]]
( ([[Doug Schepers]] 著, [TIME[2013-10-02 15:26:02 +09:00]] 版))
<http://lists.w3.org/Archives/Public/public-webevents/2013OctDec/0000.html>
[33] [CITE@en-US[Accessible Rich Internet Applications (WAI-ARIA) 1.0]]
( ([TIME[2014-01-14 16:21:51 +09:00]] 版))
<http://www.w3.org/WAI/PF/aria/complete#def_attribute>
[34] [CITE@en[XQuery and XPath Data Model 3.0]]
( ([TIME[2014-04-08 07:00:06 +09:00]] 版))
<http://www.w3.org/TR/xpath-datamodel-3/#AttributeNode>
[35] [CITE@en[Bug 25460 – muted and mediagroup should not be special-cased for the parser]]
( ([TIME[2014-06-06 11:54:47 +09:00]] 版))
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=25460>
[FIG(quote)[
[FIGCAPTION[
[9] [CITE@en-US[OPDS Catalog 1.1]]
([TIME[2015-11-19 00:28:42 +09:00]] 版)
<http://opds-spec.org/specs/opds-catalog-1-1-20110627/>
]FIGCAPTION]
> The Infoset terms "Element Information Item" and "Attribute Information Item" are shortened to "element" and "attribute" respectively. Therefore, when this specification uses the term "element", it is referring to an Element Information Item, and when it uses the term "attribute", it is referring to an Attribute Information Item.
]FIG]
[10] [CITE@en[Fix #489: 'src attribute is missing' is equal to 'no src attribute sp… · whatwg/html@3f7fda0]]
([TIME[2016-01-28 23:24:34 +09:00]] 版)
<https://github.com/whatwg/html/commit/3f7fda0be2759dc36480c8acc037d149ee831aea>
[12] [CITE@en[Use a single concept for attribute changes · whatwg/dom@4b291d1]]
([TIME[2016-04-19 17:08:52 +09:00]] 版)
<https://github.com/whatwg/dom/commit/4b291d1a91a1e8b59997d4b021137d809706bd37>