If the current node is an attribute, calling insertBefore
has the following results, depending on the value of the newChild
parameter.
Node type passed in newChild | Result |
---|---|
NODE_ATTRIBUTE , NODE_CDATA_SECTION , NODE_COMMENT , NODE_DOCUMENT , NODE_DOCUMENT_TYPE , NODE_ELEMENT , NODE_ENTITY , NODE_NOTATION , NODE_PROCESSING_INSTRUCTION |
Returns an error. These node types cannot be children of an attribute. |
NODE_DOCUMENT_FRAGMENT |
Inserts the children of the document fragment (newChild ) and returns newChild . |
NODE_ENTITY_REFERENCE, NODE_TEXT |
Inserts newChild and returns newChild . |
NODE_CDATA_SECTION , NODE_COMMENT , NODE_ENTITY, NODE_NOTATION , NODE_PROCESSING_INSTRUCTION , NODE_TEXT |
Returns an error. These node types either cannot have children or their children are read-only. |
If an entity reference is added to an attribute, the namespace and the prefix of the entity reference are added to the element containing the attribute.