Attr Interface
The Attr interface represents an attribute in an Element object.
Typically the allowable values are defined in a document type definition.
IDL Definition
Interface Attr : Node {
readonly attribute DomString name
readonly attribute boolean specified
readonly attribute DomString value
};
Semantic Requirements
- <Attr> objects are not consider to be children of the element,
therefore the parentNode, previousSibling and nextSibling attributes have a null value for <Attr> objects.
- <Attr> objects may be associated with Element nodes contained within a DocumentFragment.
- If an <Attr> is explicitly assigned any value, then that value is the
attribute's effective value.
- If there is no explicit value assigned to this attribute and there is a
declaration for this attribute and that declaration includes a default
value, then that default value is the Attribute's default value.
Attributes
- The name attribute returns the name of this Attribute node.
- The specified attribute is set to true if the attribute was
explicitly given a value in the original document, otherwise it is set to
false.
- If the user changes the value of the attribute (even if changed to the
default value), then the specified attribute is flipped to true.
- To reset an attribute to its default value (from the DTD), the attribute
must be deleted. The implementation will then make a new attribute with
the specified attribute set to false and its default value (if one
was given).
- The value attribute contains the value of the Attribute node as a string (on retrieval). Character and general entity references are replaced
with their values.
- On setting the value attribute creates a Text node with the unparsed content of the string.
DOMExceptions
- Setting the value attribute raises a NO_MODIFICATION_ALLOWED_ERR DOMException when the node is readonly.
If you have comments or suggestions, email me at mbrady@nist.gov