The NamedNodeMap
interface represents a collection of {{domxref("Attr")}} objects. Objects inside a NamedNodeMap
are not in any particular order, unlike {{domxref("NodeList")}}, although they may be accessed by an index as in an array.
A NamedNodeMap
object is live and will thus be auto-updated if changes are made to its contents internally or elsewhere.
Although called NamedNodeMap
, this interface doesn't deal with {{domxref("Node")}} objects but with {{domxref("Attr")}} objects, which were originally a specialized class of {{domxref("Node")}}, and still are in some implementations.
Properties
This interface doesn't inherit any property.
- {{domxref("NamedNodeMap.length")}} {{ReadOnlyInline}}
- Returns the amount of objects in the map.
Methods
This interface doesn't inherit any method.
- {{domxref("NamedNodeMap.getNamedItem()")}}
- Returns a {{domxref("Attr")}}, corresponding to the given name.
- {{domxref("NamedNodeMap.setNamedItem()")}}
- Replaces, or adds, the {{domxref("Attr")}} identified in the map by the given name.
- {{domxref("NamedNodeMap.removeNamedItem()")}}
- Removes the {{domxref("Attr")}} identified by the given map.
- {{domxref("NamedNodeMap.item()")}}
- Returns the {{domxref("Attr")}} at the given index, or
null
if the index is higher or equal to the number of nodes. - {{domxref("NamedNodeMap.getNamedItemNS()")}}
- Returns a {{domxref("Attr")}} identified by a namespace and related local name.
- {{domxref("NamedNodeMap.setNamedItemNS()")}}
- Replaces, or adds, the {{domxref("Attr")}} identified in the map by the given namespace and related local name.
- {{domxref("NamedNodeMap.removeNamedItemNS()")}}
- Removes the {{domxref("Attr")}} identified by the given namespace and related local name.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('DOM WHATWG', '#interface-namednodemap', 'NamedNodeMap')}} | {{Spec2('DOM WHATWG')}} | Deals with {{domxref("Attr")}} instead of {{domxref("Node")}} |
{{SpecName('DOM3 Core', 'core.html#ID-1780488922', 'NamedNodeMap')}} | {{Spec2('DOM3 Core')}} | No change from {{SpecName('DOM2 Core')}} |
{{SpecName('DOM2 Core', 'core.html#ID-1780488922', 'NamedNodeMap')}} | {{Spec2('DOM2 Core')}} | Added getNamedItemNS() , setNamedItemNS() and removeNamedItemNS() |
{{SpecName('DOM1', 'core.html#ID-1780488922', 'NamedNodeMap')}} | {{Spec2('DOM1')}} | Initial definition |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Deals with {{domxref("Attr")}} rather than {{domxref("Node")}} | {{CompatUnknown}} | {{CompatGeckoDesktop(22)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Deals with {{domxref("Attr")}} rather than {{domxref("Node")}} | {{CompatUnknown}} | {{CompatGeckoMobile(22)}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] In Gecko 22 this interface was named mozNamedAttrMap
. In Gecko 34 it was named back to NamedNodeMap
.
See also
- {{domxref("Element.attributes")}}