Search in sources :

Example 1 with NamedNodeMap

use of com.gargoylesoftware.htmlunit.javascript.NamedNodeMap in project htmlunit by HtmlUnit.

the class Element method setAttributeNode.

/**
 * Sets the attribute node for the specified attribute.
 * @param newAtt the attribute to set
 * @return the replaced attribute node, if any
 */
@JsxFunction
public Attr setAttributeNode(final Attr newAtt) {
    final String name = newAtt.getName();
    final NamedNodeMap nodes = getAttributes();
    final Attr replacedAtt = (Attr) nodes.getNamedItemWithoutSytheticClassAttr(name);
    if (replacedAtt != null) {
        replacedAtt.detachFromParent();
    }
    final DomAttr newDomAttr = newAtt.getDomNodeOrDie();
    getDomNodeOrDie().setAttributeNode(newDomAttr);
    return replacedAtt;
}
Also used : NamedNodeMap(com.gargoylesoftware.htmlunit.javascript.NamedNodeMap) DomAttr(com.gargoylesoftware.htmlunit.html.DomAttr) DomAttr(com.gargoylesoftware.htmlunit.html.DomAttr) Attr(com.gargoylesoftware.htmlunit.javascript.host.dom.Attr) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Aggregations

DomAttr (com.gargoylesoftware.htmlunit.html.DomAttr)1 NamedNodeMap (com.gargoylesoftware.htmlunit.javascript.NamedNodeMap)1 JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)1 Attr (com.gargoylesoftware.htmlunit.javascript.host.dom.Attr)1