aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/namednodemap/index.html
blob: 1aafe72d0a380113a5f956d90316b081df88b9b7 (plain)
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
---
title: NamedNodeMap
slug: Web/API/NamedNodeMap
translation_of: Web/API/NamedNodeMap
---
<div>{{APIRef("DOM")}}</div>

<p><code><strong>NamedNodeMap</strong></code> 介面表示了 {{domxref("Attr")}} 物件的集合。雖然 <code>NamedNodeMap</code> 與 {{domxref("NodeList")}} 都能如陣列一般透過索引訪問成員,但和 <code>NodeList</code> 不同的是,<code>NamedNodeMap</code> 中的成員並沒有順序。</p>

<p><code>NamedNodeMap</code> 物件具有<em>即時性(live)</em>,如果其內部成員(屬性節點物件)發生改變,<code>NamedNodeMap</code> 物件會自動更新至最新的狀態。</p>

<div class="note">
<p>僅管被稱作 <code>NamedNodeMap</code>,但本介面並不是直接用來處理節點物件({{domxref("Node")}}),而是專門負責屬性節點物件({{domxref("Attr")}})。屬性節點是一種特殊的節點,在部分瀏覽器實作中依然存在。</p>
</div>

<h2 id="屬性">屬性</h2>

<p><em>This interface doesn't inherit any property.</em></p>

<dl>
 <dt>{{domxref("NamedNodeMap.length")}} {{ReadOnlyInline}}</dt>
 <dd>Returns the amount of objects in the map.</dd>
</dl>

<h2 id="方法">方法</h2>

<p><em>This interface doesn't inherit any method.</em></p>

<dl>
 <dt>{{domxref("NamedNodeMap.getNamedItem()")}}</dt>
 <dd>Returns a {{domxref("Attr")}}, corresponding to the given name.</dd>
 <dt>{{domxref("NamedNodeMap.setNamedItem()")}}</dt>
 <dd>Replaces, or adds, the {{domxref("Attr")}} identified in the map by the given name.</dd>
 <dt>{{domxref("NamedNodeMap.removeNamedItem()")}}</dt>
 <dd>Removes the {{domxref("Attr")}} identified by the given map.</dd>
 <dt>{{domxref("NamedNodeMap.item()")}}</dt>
 <dd>Returns the {{domxref("Attr")}} at the given index, or <code>null</code> if the index is higher or equal to the number of nodes.</dd>
 <dt>{{domxref("NamedNodeMap.getNamedItemNS()")}}</dt>
 <dd>Returns a {{domxref("Attr")}} identified by a namespace and related local name.</dd>
 <dt>{{domxref("NamedNodeMap.setNamedItemNS()")}}</dt>
 <dd>Replaces, or adds, the {{domxref("Attr")}} identified in the map by the given namespace and related local name.</dd>
 <dt>{{domxref("NamedNodeMap.removeNamedItemNS()")}}</dt>
 <dd>Removes the {{domxref("Attr")}} identified by the given namespace and related local name.</dd>
</dl>

<h2 id="規範">規範</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#interface-namednodemap', 'NamedNodeMap')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td>Deals with {{domxref("Attr")}} instead of {{domxref("Node")}}</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM3 Core', 'core.html#ID-1780488922', 'NamedNodeMap')}}</td>
   <td>{{Spec2('DOM3 Core')}}</td>
   <td>No change from {{SpecName('DOM2 Core')}}</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Core', 'core.html#ID-1780488922', 'NamedNodeMap')}}</td>
   <td>{{Spec2('DOM2 Core')}}</td>
   <td>Added <code>getNamedItemNS()</code>, <code>setNamedItemNS()</code> and <code>removeNamedItemNS()</code></td>
  </tr>
  <tr>
   <td>{{SpecName('DOM1', 'core.html#ID-1780488922', 'NamedNodeMap')}}</td>
   <td>{{Spec2('DOM1')}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="瀏覽器相容性">瀏覽器相容性</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td>Deals with {{domxref("Attr")}} rather than {{domxref("Node")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop(22)}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td>Deals with {{domxref("Attr")}} rather than {{domxref("Node")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile(22)}}<sup>[1]</sup></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] In Gecko 22 this interface was named <code>mozNamedAttrMap</code>. In Gecko 34 it was named back to <code>NamedNodeMap</code>.</p>

<h2 id="參見">參見</h2>

<ul>
 <li>{{domxref("Element.attributes")}}</li>
</ul>