diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:41:15 -0500 |
commit | 4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch) | |
tree | d4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/ar/web/api/attr | |
parent | 33058f2b292b3a581333bdfb21b8f671898c5060 (diff) | |
download | translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2 translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip |
initial commit
Diffstat (limited to 'files/ar/web/api/attr')
-rw-r--r-- | files/ar/web/api/attr/index.html | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/files/ar/web/api/attr/index.html b/files/ar/web/api/attr/index.html new file mode 100644 index 0000000000..0b01877112 --- /dev/null +++ b/files/ar/web/api/attr/index.html @@ -0,0 +1,157 @@ +--- +title: Attr +slug: Web/API/Attr +translation_of: Web/API/Attr +--- +<h4 id="APIRefDOM">{{APIRef("DOM")}}</h4> + +<p>The <code><strong>Attr</strong></code> interface represents one of a DOM element's attributes as an object. In most DOM methods, you will directly retrieve the attribute as a string (e.g., {{domxref("Element.getAttribute()")}}), but certain functions (e.g., {{domxref("Element.getAttributeNode()")}}) or means of iterating return <code>Attr</code> types.</p> + +<p>{{InheritanceDiagram}}</p> + +<div class="warning"><strong>Warning: </strong>Starting in Gecko 7.0 {{geckoRelease("7.0")}}, a number of deprecated properties and methods output warning messages to the console. You should revise your code accordingly. See <a href="#Deprecated_properties_and_methods">Deprecated properties and methods</a> for a complete list.</div> + +<h2 id="Properties">Properties</h2> + +<dl> + <dt>{{domxref("Attr.name", "name")}} {{readOnlyInline}}</dt> + <dd>The attribute's name.</dd> + <dt>{{domxref("Attr.namespaceURI", "namespaceURI")}} {{readOnlyInline}}</dt> + <dd>A {{domxref("DOMString")}} representing the namespace URI of the attribute, or <code>null</code> if there is no namespace.</dd> + <dt>{{domxref("Attr.localName", "localName")}} {{readOnlyInline}}</dt> + <dd>A {{domxref("DOMString")}} representing the local part of the qualified name of the attribute.</dd> + <dt>{{domxref("Attr.prefix", "prefix")}} {{readOnlyInline}}</dt> + <dd>A {{domxref("DOMString")}} representing the namespace prefix of the attribute, or <code>null</code> if no prefix is specified.</dd> + <dt>{{domxref("Attr.ownerElement", "ownerElement")}} {{readOnlyInline}}</dt> + <dd> + <p>The element holding the attribute.</p> + + <div class="note"> + <p><strong>Note:</strong> DOM Level 4 removed this property. The assumption was that since you get an <code>Attr</code> object from an {{domxref("Element")}}, you should already know the associated element.<br> + As that doesn't hold true in cases like <code>Attr</code> objects being returned by {{domxref("Document.evaluate")}}, the DOM Living Standard reintroduced the property.</p> + + <p>Gecko outputs a deprecation note starting from Gecko 7.0 {{geckoRelease("7.0")}}. This note was removed again in Gecko 49.0 {{geckoRelease("49.0")}}.</p> + </div> + </dd> + <dt>{{domxref("Attr.specified", "specified")}} {{readOnlyInline}}</dt> + <dd>This property always returns <code>true</code>. Originally, it returned <code>true </code>if the attribute was explicitly specified in the source code or by a script, and <code>false</code> if its value came from the default one defined in the document's <acronym title="Document Type Definition">DTD</acronym>.</dd> + <dt>{{domxref("Attr.value", "value")}}</dt> + <dd>The attribute's value.</dd> +</dl> + +<div class="note"> +<p><strong>Note:</strong> DOM Level 3 defined <code>namespaceURI</code>, <code>localName</code> and <code>prefix</code> on the {{domxref("Node")}} interface. In DOM4 they were moved to <code>Attr</code>.</p> + +<p>This change is implemented in Chrome since version 46.0 and Firefox since version 48.0.</p> +</div> + +<h2 id="Deprecated_properties_and_methods">Deprecated properties and methods</h2> + +<p>The following properties have been deprecated. Where available, the appropriate replacement is noted.</p> + +<dl> + <dt><code>attributes</code></dt> + <dd>This property now always returns <code>NULL</code>.</dd> + <dt><code>childNodes</code> {{obsolete_inline(14)}}</dt> + <dd>This property now always returns an empty {{domxref("NodeList")}}.</dd> + <dt><code>firstChild</code> {{obsolete_inline(14)}}</dt> + <dd>This property now always returns <code>NULL</code>.</dd> + <dt><code>isId</code> {{readOnlyInline}}</dt> + <dd>Indicates whether the attribute is an "ID attribute". An "ID attribute" being an attribute which value is expected to be unique across a DOM Document. In HTML DOM, "id" is the only ID attribute, but XML documents could define others. Whether or not an attribute is unique is often determined by a {{Glossary("DTD")}} or other schema description.</dd> + <dt><code>lastChild</code> {{obsolete_inline(14)}}</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> + <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>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>schemaTypeInfo</code> {{obsolete_inline}} {{readOnlyInline}}</dt> + <dd>The type information associated with this attribute. While the type information contained in this attribute is guaranteed to be correct after loading the document or invoking {{domxref("Document.normalizeDocument")}}, this property may not be reliable if the node was moved.</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> {{obsolete_inline(14)}}</dt> + <dd>Modify the value of {{domxref("Attr.value")}} instead.</dd> + <dt><code>cloneNode()</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>createAttribute()</code></dt> + <dd>Use {{domxref("Element.setAttribute()")}} instead.</dd> + <dt><code>createAttributeNS()</code></dt> + <dd>Use {{domxref("Element.setAttributeNS()")}} instead.</dd> + <dt><code>getAttributeNode()</code></dt> + <dd>Use {{domxref("Element.getAttribute()")}} instead.</dd> + <dt><code>getAttributeNodeNS()</code></dt> + <dd>Use {{domxref("Element.getAttributeNS()")}} instead.</dd> + <dt><code>hasAttributes()</code> {{obsolete_inline("21.0")}}</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> + <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>normalize()</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>removeAttributeNode()</code></dt> + <dd>Use {{domxref("Element.removeAttribute()")}} instead.</dd> + <dt><code>removeChild()</code> {{obsolete_inline(14)}}</dt> + <dd>Modify the value of {{domxref("Attr.value")}} instead.</dd> + <dt><code>replaceChild()</code> {{obsolete_inline(14)}}</dt> + <dd>Modify the value of {{domxref("Attr.value")}} instead.</dd> + <dt><code>setAttributeNode()</code></dt> + <dd>Use {{domxref("Element.setAttribute()")}} instead.</dd> + <dt><code>setAttributeNodeNS()</code></dt> + <dd>Use {{domxref("Element.setAttributeNS()")}} instead.</dd> +</dl> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("DOM WHATWG", "#interface-attr", "Attr")}}</td> + <td>{{Spec2("DOM WHATWG")}}</td> + <td>Added <code>ownerElement</code> property back</td> + </tr> + <tr> + <td>{{SpecName("DOM4", "#interface-attr", "Attr")}}</td> + <td>{{Spec2("DOM4")}}</td> + <td>Moved <code>namespaceURI</code>, <code>prefix</code> and <code>localName</code> from {{domxref("Node")}} to this API and removed <code>ownerElement</code>, <code>schemaTypeInfo</code> and <code>isId</code>.</td> + </tr> + <tr> + <td>{{SpecName("DOM3 Core", "core.html#ID-637646024", "Attr")}}</td> + <td>{{Spec2("DOM3 Core")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("api.Attr")}}</p> |