-
Notifications
You must be signed in to change notification settings - Fork 4
/
37.txt
247 lines (199 loc) · 11.6 KB
/
37.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
* 仕様書
[REFS[
- [20] [CITE@en-US[DOM Standard]] ([TIME[2012-11-23 14:12:13 +09:00]] 版) <http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature>
- [22] [CITE[Scalable Vector Graphics (SVG) 2]] ([TIME[2012-11-29 19:07:20 +09:00]] 版) <https://svgwg.org/svg2-draft/single-page.html#chapter-feature>
- [23] [CITE[Scalable Vector Graphics (SVG) 2]] ([TIME[2012-11-29 19:07:20 +09:00]] 版) <https://svgwg.org/svg2-draft/single-page.html#svgdom-FeatureStrings>
- [24] [CITE[Scalable Vector Graphics (SVG) 2]] ([TIME[2012-11-29 19:07:20 +09:00]] 版) <https://svgwg.org/svg2-draft/single-page.html#struct-ConditionalProcessingRequiredFeaturesAttribute>
]REFS]
* 構文
[3] 機能名では、大文字・小文字は区別されません [SRC[DOM 1 [ABBR[FE] [First Edition]] [CODE(DOMm)[hasFeature]], DOM 1 [ABBR[SE] [Second Edition]] [CODE(DOMm)[hasFeature]], DOM 2 Core [CODE(DOMm)[hasFeature]], DOM 3 Core 1.3.6]]。
DOM 1 [ABBR[FE] [First Edition]] では、 [SAMP(DOM)[HTML]] と [SAMP(DOM)[XML]]
の2つの値だけが認められていました
[SRC[DOM 1 [ABBR[FE] [First Edition]] [CODE(DOMm)[hasFeature]]]]。
DOM 1 [ABBR[SE] [Second Edition]] と DOM 2 は、
[[XML 1.0]] の [CODE(ABNF)[[[Name]]]] でなければならないとしています
[SRC[DOM 1 [ABBR[SE] [Second Edition]] [CODE(DOMm)[hasFeature]], DOM 2 Core [CODE(DOMm)[hasFeature]]]]。
DOM 3 にはこのような制限はないようです。
[9]
>>3 だけしか規定がないようですが、
[CODE(DOMp)[[[features]]]] で使い物になる値にしたければ、次の配慮が必要です。
- 最初の1文字に [CODE(char)[+]] を使わない
- [CODE(char)[[[SP]]]] を使わない
- 名前は数字からはじめない。
版は数字からはじめる。
版は、メソッドの引数として使われるところで [Q[version number]]
とされていますから、数しか認められないと思われます。
DOM 1 では [SAMP(DOM)[1.0]] だけ、 DOM 2 では [SAMP(DOM)[1.0]] と
[SAMP(DOM)[2.0]] だけが指定できるとされていました
[SRC[DOM 1 [ABBR[FE] [First Edition]] [CODE(DOMm)[hasFeature]], DOM 1 [ABBR[SE] [Second Edition]] [CODE(DOMm)[hasFeature]], DOM 2 Core [CODE(DOMm)[hasFeature]]]]。
DOM 3 ではそのような制限はないようです。
[11]
衝突の虞を防ぐため、 DOM 仕様書以外で定義する機能の名前は固有にするべきです。
衝突を防ぐ方法として、以前は[[逆ドメイン名]]を使うべきとされていました
[SRC[DOM 1 [ABBR[SE] [Second Edition]] [CODE(DOMm)[hasFeature]], DOM 2 Core [CODE(DOMm)[hasFeature]]]] が、
後に DOM 仕様書の規定外に改められました [SRC[DOM 2 Errata core-5, DOM 3 Core 1.3.6]]。
[[SVG 1.0]] の DOM は逆ドメイン名の機能名を使っていましたが、
[[SVG 1.1]] では [[URI参照]]を使っています。 SVG の DOM
以外の機能名やプログラム言語・ライブラリ等で機能名を識別するために
URI 参照が使われることが増えており、そのため逆ドメイン名より自由度が高い
URI 参照を使えるようにと DOM の規定も変更されたのでしょう。
[[#comment]]
* 既知の値
[4]
,機能名 ,版 ,説明
,[CODE(DOM)[[[Core]]]] ,[CODE(DOM)[2.0]] ,Core Module (Level 2) [SRC[DOM 2 Core 1.2]] ,DOM 3 Core 1.4]]
,[CODE(DOM)[Core]] ,[CODE(DOM)[3.0]] ,Core Module (Level 3) [SRC[DOM 3 Core 1.4]]
,[CODE(DOM)[[[DDE-T]]]] ,[CODE(DOM)[1.0]] ,[SRC[DDE]]
,[CODE(DOM)[[[HTML]]]] ,[CODE(DOM)[1.0]] ,HTML Module (Level 1) [SRC[DOM 1 2.1]]
,[CODE(DOM)[[[org.atsc.dom.core]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.atsc.dom.environment]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.atsc.dom.events]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.atsc.dom.html]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.atsc.dom.native]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.atsc.dom.views]]]] , , ,[SRC[DASE]]
,[CODE(DOM)[[[org.w3c.dom.smil]]]] , ,SMIL DOM の例 [SRC[DOM 1 [ABBR[SE] [Second Edition]] [CODE(DOMm)[hasFeature]]]]
,[CODE(DOM)[[[org.w3c.dom.svg]]]] , ,SVG DOM の例 [SRC[DOM 2 Core [CODE(DOMm)[hasFeature]]]]
,[CODE(DOM)[[[XML]]]] ,[CODE(DOM)[1.0]] ,XML Module (Level 1) [SRC[DOM 1 1.3]] ,DOM 3 Core 1.5]]
,[CODE(DOM)[XML]] ,[CODE(DOM)[2.0]] ,XML Module (Level 2) [SRC[DOM 2 Core 1.3]] ,DOM 3 Core 1.5]]
,[CODE(DOM)[XML]] ,[CODE(DOM)[3.0]] ,XML Module (Level 3) [SRC[DOM 3 Core 1.5]]
,[CODE(DOM)[[[XMLVersion]]]] ,[CODE(DOM)[1.0]] ,[[XML 1.0]] [SRC[DOM 3 Core [CODE(DOMa)[xmlVersion]]]] ,DOM 3 Core 1.5]]
,[CODE(DOM)[XMLVersion]] ,[CODE(DOM)[1.1]] ,[[XML 1.1]] [SRC[DOM 3 Core [CODE(DOMa)[xmlVersion]]]]
[10]
- [[DOM 1]]
-- [ABBR[SE] [Second Edition]] Compliance
<IW:DOM1:"introduction.html#ID-Compliance">
-- 1.3. Extended Interfaces
<IW:DOM1:"level-one-core.html#ID-E067D597">
-- 2.1. Introduction
<IW:DOM1:"level-one-html.html#ID-1176245063">
- [[DOM 2]]
-- Core Conformance
<IW:DOM2:"Core/introduction.html#ID-Conformance">
-- Core 1.2. Fundamental Interfaces
<IW:DOM2:"Core/core.html#ID-BBACDC08">
-- Core 1.3. Extended Interfaces
<IW:DOM2:"Core/core.html#ID-E067D597">
- [[DOM 3]]
-- Core Conformance
<IW:DOM3:"Core/introduction.html#ID-Conformance">
-- Core 1.4 Fundamental Interfaces: Core Module
<IW:DOM3:"Core/core.html#ID-BBACDC08">
-- Core [CODE(DOMa)[xmlVersion]]
<IW:DOM3:"Core/core.html#Document3-version">
-- Core 1.5 Extended Interfaces: XML Module
<IW:DOM3:"Core/core.html#ID-E067D597">
- [DASE] [CITE[DTV A S E L 1 (DASE-1) P 2: D A E ATSC Standard]]
<http://www.atsc.org/standards/a_100_2.pdf>
-- [CSECTION[5.3.1.2.1.4.1 DOMImplementation::hasFeature]]
- [DDE] [CITE[Declarative Data Essence -- Transitional]] <http://www.smpte.org/standards/pdf/s397m.pdf>
-- [CSECTION[8.1 DOM and Host Object Basis]]
[[#comment]]
* 他との関係
[5] 応用は、メソッド
[CODE(DOMm)[[[getDOMImplementation]] ([VAR(DOMp)[features]])]] やメソッド
[CODE(DOMm)[[[getDOMImplementationList]] ([VAR(DOMp)[features]])]]
を使うと特定の機能を実装した DOM [[実装]]を要求できます。
メソッド [CODE(DOMm)[[[hasFeature]] ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
やメソッド [CODE(DOMm)[[[isSupported]] ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
を使うと特定の機能が実装されているか調べることができます。
(版を問わない時は [CODE(DOM)[[[null]]]] や空文字列を指定できます。)
[6]
DOM 2 モジュールまででは、既存の界面の拡張である界面はみな、
その拡張に対応する機能に対応していれば、束縛規定の型変換機構を使って利用することができました。
(例えば、 [CODE(DOM)[[[Events]]]] 機能に対応していれば
[CODE(DOMi)[[[Node]]]] の実現値から [CODE(DOMi)[[[EventTarget]]]]
(is‐a [CODE(DOMi)[Node]]) の実現値を得ることができました。)
DOM 3 では、特定の DOM を実装する部分部品と強調できるべきとされています
([[DOM//実装//混合]]を参照してください)。このため、メソッド
[CODE(DOMm)[[[getFeature]] ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
が用意されており、特定の機能を実装した実現値を得ることができます。
[7] メソッド
[CODE(DOMm)[hasFeature ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
やメソッド
[CODE(DOMm)[isSupported ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
では、 [CODE(DOMp)[feature]] 名の前に [CODE(char)[+]]
を付けることができます。付けなければ直接型変換可能な界面の機能だけが考慮されますが、
付けた場合は [CODE(DOMm)[getFeature ([VAR(DOMp)[feature]], [VAR(DOMp)[version]])]]
を使って得られるものも考慮に入れられます。
* 歴史
** W3C DOM
[1] 各 [[DOM]] モジュールは1つ以上の[DFN[[RUBYB[機能] [feature]]]]
(名前と版) を定義します。
[REFS[
- [2] [[DOM 1]]
-- Core [CODE(DOMm)[hasFeature]]
<IW:DOM1:"level-one-core.html#ID-5CED94D7">
-- Errata Section 1.2 Interface DOMImplementation
<http://www.w3.org/DOM/updates/REC-DOM-Level-1-19981001-errata.html>
- [[DOM 2]]
-- Core [CODE(DOMm)[hasFeature]]
<IW:DOM2:"Core/core.html#ID-5CED94D7">
-- Errata core-5. 2001-01-17. [error]. DOMImplementation.hasFeature
<http://www.w3.org/2000/11/DOM-Level-2-errata#core-5>
-- Errata core-14. 2001-07-11. [clarification]. DOMImplementation.hasFeature
<http://www.w3.org/2000/11/DOM-Level-2-errata#core-14>
- [[DOM 3]]
-- Core 1.3.6 DOM Features
<IW:DOM3:"Core/core.html#DOMFeatures">
-- Core [CODE(DOMm)[getDOMImplementation]]
<IW:DOM3:"Core/core.html#ID-getDOMImpl">
-- Core [CODE(DOMm)[getDOMImplementationList]]
<IW:DOM3:"Core/core.html#ID-getDOMImpls">
-- Core [CODE(DOMm)[getFeature]]
<IW:DOM3:"Core/core.html#DOMImplementation3-getFeature">
-- Core [CODE(DOMm)[hasFeature]]
<IW:DOM3:"Core/core.html#ID-5CED94D7">
-- Core [CODE(DOMm)[getFeature]]
<IW:DOM3:"Core/core.html#Node3-getFeature">
]REFS]
** SVG
[REFS[
- [15] [CITE[SVG Document Object Model (DOM) – SVG 1.1 (Second Edition)]] ([TIME[2011-08-10 03:35:27 +09:00]] 版) <http://www.w3.org/TR/SVG/svgdom.html#FeatureStrings>
- [14] [CITE[Feature Strings – SVG 1.1 (Second Edition)]] ([TIME[2011-08-10 03:35:27 +09:00]] 版) <http://www.w3.org/TR/SVG/feature.html>
]REFS]
*** SVG 1.0
[REFS[
- [17] [CITE[Document Structure - SVG 1.0 - 20010904]] ([TIME[2001-09-01 01:37:36 +09:00]] 版) <http://www.w3.org/TR/2001/REC-SVG-20010904/struct.html#RequiredFeaturesAttribute>
- [16] [CITE[SVG Document Object Model (DOM) - SVG 1.0 - 20010904]] ([TIME[2001-09-01 01:37:36 +09:00]] 版) <http://www.w3.org/TR/2001/REC-SVG-20010904/svgdom.html#FeatureStrings>
]REFS]
*** SVG 1.1
@@
*** SVG 1.2
[REFS[
- [18] [CITE[Feature Strings – SVG Tiny 1.2]] ([TIME[2008-12-19 17:31:29 +09:00]] 版) <http://www.w3.org/TR/SVGTiny12/feature.html>
- [19] [CITE[Document Structure – SVG Tiny 1.2]] ([TIME[2008-12-19 17:31:29 +09:00]] 版) <http://www.w3.org/TR/SVGTiny12/struct.html#RequiredFeaturesAttribute>
]REFS]
** WHATWG
@@ HTML5
[REFS[
- [21] [CITE@en-US[DOM Standard]] ([TIME[2012-11-23 14:12:13 +09:00]] 版) <http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature>
]REFS]
* 例
[8] 型変換の例:
[PRE[
my EventTarget $evt;
if ($node.[CODE(DOMm)[isSupported ([CODE(DOMp)["Events"]], [CODE(DOMp)["3.0"]])]]) {
## 直接型変換可能な場合
$evt = (EventTarget) $node;
} else if ($node.[CODE(DOMm)[isSupported ([CODE(DOMp)["+Events"]], [CODE(DOMp)["3.0"]])]]) {
## 間接的に型変換可能な場合
$evt = (EventTarget) $node.[CODE(DOMm)[getFeature ([CODE(DOMp)["Events"]], [CODE(DOMp)["3.0"]])]];
}
]PRE]
[[#comment]]
* memo
[12]
実装によっては Core, 1.0 に true を返します。
([[名無しさん]])
[13] [CITE@en[DOM features - WHATWG Wiki]]
( ([TIME[2012-04-07 02:07:28 +09:00]] 版))
<http://wiki.whatwg.org/wiki/DOM_features>
[25] [CITE@en[Web Applications 1.0 r7562 Update references to DOM spec so they call it its real name. (Boy am I late to _this_ party.) This update will also make <iframe seamless> do event retargetting once DOM is updated to support that (see bug 18780 - marked this bug 'editorial' since this change doesn't work without the DOM stuff). Also, a lot of clean-up to affected areas.]]
( ([TIME[2012-12-05 08:55:00 +09:00]] 版))
<http://html5.org/tools/web-apps-tracker?from=7561&to=7562>
[26] [CITE[Document Object Model for MathML]]
( ([TIME[2001-02-20 21:36:11 +09:00]] 版))
<http://www.w3.org/TR/2001/REC-MathML2-20010221/chapter8.html>
[27] [CITE@EN[Delivery Context: Client Interfaces (DCCI) 1.0]]
( ([TIME[2007-12-11 04:28:19 +09:00]] 版))
<http://www.w3.org/TR/2007/CR-DPF-20071221/#iddiv296456272>