AwaitedDOM/ Attr

The Attr 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., Element.getAttribute()), but certain functions (e.g., Element.getAttributeNode()) or means of iterating return Attr types.

Properties

.localName
W3C

A string representing the local part of the qualified name of the attribute.

Type: Promise<string>

.name
W3C

The attribute's name.

Type: Promise<string>

.namespaceURI
W3C

A string representing the namespace URI of the attribute, or null if there is no namespace.

Type: Promise<string>

.ownerElement
W3C

The element holding the attribute.

Note: DOM Level 4 removed this property. The assumption was that since you get an Attr object from an Element, you should already know the associated element.
As that doesn't hold true in cases like Attr objects being returned by Document.evaluate, the DOM Living Standard reintroduced the property.

Gecko outputs a deprecation note starting from Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4). This note was removed again in Gecko 49.0 (Firefox 49.0 / Thunderbird 49.0 / SeaMonkey 2.46).

Type: SuperElement

.prefix
W3C

A string representing the namespace prefix of the attribute, or null if no prefix is specified.

Type: Promise<string>

.specified
W3C

This property always returns true. Originally, it returned true if the attribute was explicitly specified in the source code or by a script, and false if its value came from the default one defined in the document's DTD.

Type: Promise<boolean>

.value
W3C

The attribute's value.

Type: Promise<string>

.baseURI
W3C

Returns a string representing the base URL of the document containing the Node.

Type: Promise<string>

.childNodes
W3C

Returns a live NodeList containing all the children of this node. NodeList being live means that if the children of the Node change, the NodeList object is automatically updated.

Type: SuperNodeList

.firstChild
W3C

Returns a Node representing the first direct child node of the node, or null if the node has no child.

Type: SuperNode

.isConnected
W3C

A boolean indicating whether or not the Node is connected (directly or indirectly) to the context object, e.g. the Document object in the case of the normal DOM, or the ShadowRoot in the case of a shadow DOM.

Type: Promise<boolean>

.lastChild
W3C

Returns a Node representing the last direct child node of the node, or null if the node has no child.

Type: SuperNode

.nextSibling
W3C

Returns a Node representing the next node in the tree, or null if there isn't such node.

Type: SuperNode

.nodeName
W3C

Returns a string containing the name of the Node. The structure of the name will differ with the node type. E.g. An HTMLElement will contain the name of the corresponding tag, like 'audio' for an HTMLAudioElement, a Text node will have the '#text' string, or a Document node will have the '#document' string.

Type: Promise<string>

.nodeType
W3C

Returns an unsigned short representing the type of the node. Possible values are:

NameValue
ELEMENT_NODE1
ATTRIBUTE_NODE 2
TEXT_NODE3
CDATA_SECTION_NODE4
ENTITY_REFERENCE_NODE 5
ENTITY_NODE 6
PROCESSING_INSTRUCTION_NODE7
COMMENT_NODE8
DOCUMENT_NODE9
DOCUMENT_TYPE_NODE10
DOCUMENT_FRAGMENT_NODE11
NOTATION_NODE 12

Type: Promise<number>

.nodeValue
W3C

Returns / Sets the value of the current node.

Type: Promise<string>

.ownerDocument
W3C

Returns the Document that this node belongs to. If the node is itself a document, returns null.

Type: SuperDocument

.parentElement
W3C

Returns an Element that is the parent of this node. If the node has no parent, or if that parent is not an Element, this property returns null.

Type: SuperElement

.parentNode
W3C

Returns a Node that is the parent of this node. If there is no such node, like if this node is the top of the tree or if doesn't participate in a tree, this property returns null.

Type: SuperNode

.previousSibling
W3C

Returns a Node representing the previous node in the tree, or null if there isn't such node.

Type: SuperNode

.textContent
W3C

Returns / Sets the textual content of an element and all its descendants.

Type: Promise<string>

Methods

.compareDocumentPosition(other)
W3C

Compares the position of the current node against another node in any other document.

Arguments:

  • other Node. The other Node with which to compare the first node’s document position.

Returns: Promise<number>

.contains(other)
W3C

Returns a boolean value indicating whether or not a node is a descendant of the calling node.

Arguments:

  • other Node. Needs content.

Returns: Promise<boolean>

.getRootNode(options?)
W3C

Returns the context object's root which optionally includes the shadow root if it is available. 

Arguments:

  • options GetRootNodeOptions. An object that sets options for getting the root node. The available options are:
    • composed: A `boolean` that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).

Returns: SuperNode

.hasChildNodes()
W3C

Returns a boolean indicating whether or not the element has any child nodes.

Returns: Promise<boolean>

.isDefaultNamespace(namespace)
W3C

Accepts a namespace URI as an argument and returns a boolean with a value of true if the namespace is the default namespace on the given node or false if not.

Arguments:

  • namespace string. namespaceURI is a string representing the namespace against which the element will be checked.

Returns: Promise<boolean>

.isEqualNode(otherNode)
W3C

Returns a boolean which indicates whether or not two nodes are of the same type and all their defining data points match.

Arguments:

  • otherNode Node. otherNode: The Node to compare equality with.

Returns: Promise<boolean>

.isSameNode(otherNode)
W3C

Returns a boolean value indicating whether or not the two nodes are the same (that is, they reference the same object).

Arguments:

  • otherNode Node. otherNode The Node to test against.

Returns: Promise<boolean>

.lookupNamespaceURI(prefix)
W3C

Accepts a prefix and returns the namespace URI associated with it on the given node if found (and null if not). Supplying null for the prefix will return the default namespace.

Arguments:

  • prefix string. The prefix to look for. If this parameter is null, the method will return the default namespace URI, if any.

Returns: Promise<string>

.lookupPrefix(namespace)
W3C

Returns a string containing the prefix for a given namespace URI, if present, and null if not. When multiple prefixes are possible, the result is implementation-dependent.

Arguments:

  • namespace string. Needs content.

Returns: Promise<string>

.normalize()
W3C

Clean up all the text nodes under this element (merge adjacent, remove empty).

Returns: Promise<void>

Unimplemented Specs

Methods

appendChild()cloneNode()
insertBefore()removeChild()
replaceChild()addEventListener()
dispatchEvent()removeEventListener()

Edit this page on GitHub