use of com.gargoylesoftware.htmlunit.javascript.host.dom.Attr 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;
}
use of com.gargoylesoftware.htmlunit.javascript.host.dom.Attr in project htmlunit by HtmlUnit.
the class XMLDocument method makeScriptableFor.
/**
* {@inheritDoc}
*/
@Override
public HtmlUnitScriptable makeScriptableFor(final DomNode domNode) {
final HtmlUnitScriptable scriptable;
// TODO: cleanup, getScriptObject() should be used!!!
if (domNode instanceof DomElement && !(domNode instanceof HtmlElement)) {
if (domNode instanceof SvgElement) {
final Class<? extends HtmlUnitScriptable> javaScriptClass = ((JavaScriptEngine) getWindow().getWebWindow().getWebClient().getJavaScriptEngine()).getJavaScriptClass(domNode.getClass());
try {
scriptable = javaScriptClass.newInstance();
} catch (final Exception e) {
throw Context.throwAsScriptRuntimeEx(e);
}
} else {
scriptable = new Element();
}
} else if (domNode instanceof DomAttr) {
scriptable = new Attr();
} else {
return super.makeScriptableFor(domNode);
}
scriptable.setPrototype(getPrototype(scriptable.getClass()));
scriptable.setParentScope(getParentScope());
scriptable.setDomNode(domNode);
return scriptable;
}
Aggregations