mozilla

Revision 70467 of Attr

  • Revision slug: DOM/Attr
  • Revision title: Attr
  • Revision id: 70467
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment updated for bug 687668; 578 words added, 23 words removed
Tags: 

Revision Content

This type represents a DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., {{ domxref("Element.getAttribute()") }}, but certain functions (e.g., {{ domxref("Element.getAttributeNode()") }}) or means of iterating give Attr types. Also inherits the {{ domxref("Node") }} methods and properties.

Warning: In order to bring the implementation of Attr up to specification, work is underway to change it to no longer inherit from {{ domxref("Node") }}. You should not be using any {{ domxref("Node") }} properties or methods on Attr objects. Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, the ones that are going to be removed output warning messages to the console. You should revise your code accordingly. See {{ anch("Deprecated properties and methods") }} for a complete list.

Properties

isId
?
name
The attribute's name.
ownerElement {{ deprecated_inline("7.0") }}
This property has been deprecated and will be removed in the future. Since you can only get Attr objects from elements, you should already know th
schemaTypeInfo
?
specified {{ deprecated_inline("7.0") }}
This property has been deprecated and will be removed in the future; it now always returns true.
value
The attribute's value.

Deprecated properties and methods

The following properties have been deprecated. Where available, the appropriate replacement is provided.

attributes
This property now always returns NULL.
childNodes
This property now always returns NULL.
firstChild
This property now always returns NULL.
lastChild
This property now always returns NULL.
nextSibling
This property now always returns NULL.
nodeName
Use {{ domxref("Attr.name") }} instead.
nodeType
This property now always returns 2 (ATTRIBUTE_NODE).
nodeValue
Use {{ domxref("Attr.value") }} instead.
ownerDocument

You shouldn't have been using this in the first place, so you probably don't care that this is going away.

ownerElement
Since you get an Attr object from an {{ domxref("Element") }}, you should already know the associated element.
parentNode
This property now always returns NULL.
previousSibling
This property now always returns NULL.
specified
This property now always returns true.
textContent
Use {{ domxref("Attr.value") }} instead.

The following methods have been deprecated:

appendChild()
Modify the value of {{ domxref("Attr.value") }} instead.
cloneNode()
?
createAttribute()
Use {{ domxref("Attr.setAttribute()") }} instead.
createAttributeNS()
Use {{ domxref("Attr.setAttributeNS()") }} instead.
getAttributeNode()
Use {{ domxref("Attr.getAttribute()") }} instead.
getAttributeNodeNS()
Use {{ domxref("Attr.getAttributeNS()") }} instead.
hasAttributes()
This method now always returns false.
hasChildNodes()
This method now always returns false.
insertBefore()
Modify the value of {{ domxref("Attr.value") }} instead.
isSupported()
You shouldn't have been using this in the first place, so you probably don't care that this is going away.
isEqualNode()

You shouldn't have been using this in the first place, so you probably don't care that this is going away.

normalize()

You shouldn't have been using this in the first place, so you probably don't care that this is going away.

removeAttributeNode()
Use {{ domxref("Attr.removeAttribute()") }} instead.
removeChild()
Modify the value of {{domxref("Attr.value)")) instead.
replaceChild()
Modify the value of {{ domxref("Attr.value") }} instead.
setAttributeNode()
Use {{ domxref("Attr.setAttribute()") }} instead.
setAttributeNodeNS()
Use {{ domxref("Attr.setAttributeNS()") }} instead.

Specification

Revision Source

<p>This type represents a DOM element's attribute as an object. In most DOM methods, you will probably directly retrieve the attribute as a string (e.g., {{ domxref("Element.getAttribute()") }}, but certain functions (e.g., {{ domxref("Element.getAttributeNode()") }}) or means of iterating give <code>Attr</code> types. Also inherits the {{ domxref("Node") }} methods and properties.</p>
<div class="warning"><strong>Warning:</strong> In order to bring the implementation of <code>Attr</code> up to specification, work is underway to change it to no longer inherit from {{ domxref("Node") }}. You should not be using any {{ domxref("Node") }} properties or methods on <code>Attr</code> objects. Starting in Gecko 7.0 {{ geckoRelease("7.0") }}, the ones that are going to be removed output warning messages to the console. You should revise your code accordingly. See {{ anch("Deprecated properties and methods") }} for a complete list.</div>
<h3>Properties</h3>
<dl> <dt><code><a class="internal" href="/En/DOM/Attr.isId" title="En/DOM/Attr.isId">isId</a></code></dt> <dd>?</dd> <dt><code><a class="internal" href="/En/DOM/Attr.name" title="En/DOM/Attr.name">name</a></code></dt> <dd>The attribute's name.</dd> <dt><code><a class="internal" href="/En/DOM/Attr.ownerElement" title="En/DOM/Attr.ownerElement">ownerElement</a></code> {{ deprecated_inline("7.0") }}</dt> <dd>This property has been deprecated and will be removed in the future. Since you can only get Attr objects from elements, you should already know th</dd> <dt><code><a class="internal" href="/En/DOM/Attr.schemaTypeInfo" title="En/DOM/Attr.schemaTypeInfo">schemaTypeInfo</a></code></dt> <dd><code>?</code></dd> <dt><code><a class="internal" href="/En/DOM/Attr.specified" title="En/DOM/Attr.specified">specified </a></code>{{ deprecated_inline("7.0") }}</dt> <dd>This property has been deprecated and will be removed in the future; it now always returns <code>true</code>.</dd> <dt><code><a class="internal" href="/En/DOM/Attr.value" title="En/DOM/Attr.value">value</a></code></dt> <dd>The attribute's value.</dd>
</dl>
<h3>Deprecated properties and methods</h3>
<p>The following properties have been deprecated. Where available, the appropriate replacement is provided.</p>
<dl> <dt><code>attributes</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>childNodes</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>firstChild</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>lastChild</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>nextSibling</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>nodeName</code></dt> <dd>Use {{ domxref("Attr.name") }} instead.</dd> <dt><code>nodeType</code></dt> <dd>This property now always returns 2 (<code>ATTRIBUTE_NODE</code>).</dd> <dt><code>nodeValue</code></dt> <dd>Use {{ domxref("Attr.value") }} instead.</dd> <dt><code>ownerDocument</code></dt>
</dl>
<p>You shouldn't have been using this in the first place, so you probably don't care that this is going away.</p>
<dl> <dt><code>ownerElement</code></dt> <dd>Since you get an <code>Attr</code> object from an {{ domxref("Element") }}, you should already know the associated element.</dd> <dt><code>parentNode</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>previousSibling</code></dt> <dd>This property now always returns <code>NULL</code>.</dd> <dt><code>specified</code></dt> <dd>This property now always returns <code>true</code>.</dd> <dt><code>textContent</code></dt> <dd>Use {{ domxref("Attr.value") }} instead.</dd>
</dl>
<p>The following methods have been deprecated:</p>
<dl> <dt><code>appendChild()</code></dt> <dd>Modify the value of {{ domxref("Attr.value") }} instead.</dd> <dt><code>cloneNode()</code></dt> <dd>?</dd> <dt><code>createAttribute()</code></dt> <dd>Use {{ domxref("Attr.setAttribute()") }} instead.</dd> <dt><code>createAttributeNS()</code></dt> <dd>Use {{ domxref("Attr.setAttributeNS()") }} instead.</dd> <dt><code>getAttributeNode()</code></dt> <dd>Use {{ domxref("Attr.getAttribute()") }} instead.</dd> <dt><code>getAttributeNodeNS()</code></dt> <dd>Use {{ domxref("Attr.getAttributeNS()") }} instead.</dd> <dt><code>hasAttributes()</code></dt> <dd>This method now always returns false.</dd> <dt><code>hasChildNodes()</code></dt> <dd>This method now always returns false.</dd> <dt><code>insertBefore()</code></dt> <dd>Modify the value of {{ domxref("Attr.value") }} instead.</dd> <dt><code>isSupported()</code></dt> <dd>You shouldn't have been using this in the first place, so you probably don't care that this is going away.</dd> <dt><code>isEqualNode()</code></dt>
</dl>
<p>You shouldn't have been using this in the first place, so you probably don't care that this is going away.</p>
<dl> <dt><code>normalize()</code></dt>
</dl>
<p>You shouldn't have been using this in the first place, so you probably don't care that this is going away.</p>
<dl> <dt><code>removeAttributeNode()</code></dt> <dd>Use {{ domxref("Attr.removeAttribute()") }} instead.</dd> <dt><code>removeChild()</code></dt> <dd>Modify the value of {{domxref("Attr.value)")) instead.</dd> <dt><code>replaceChild()</code></dt> <dd>Modify the value of {{ domxref("Attr.value") }} instead.</dd> <dt><code>setAttributeNode()</code></dt> <dd>Use {{ domxref("Attr.setAttribute()") }} instead.</dd> <dt><code>setAttributeNodeNS()</code></dt> <dd>Use {{ domxref("Attr.setAttributeNS()") }} instead.</dd>
</dl>
<h3>Specification</h3>
<ul> <li><a class=" external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-637646024" title="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-637646024">Document Object Model Core: Interface Attr</a></li>
</ul>
Revert to this revision