use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLStyleElement method setDisabled.
/**
* Sets the {@code disabled} property.
* @param disabled the {@code disabled} property
*/
@Override
@JsxSetter
public void setDisabled(final boolean disabled) {
final CSSStyleSheet sheet = getSheet();
final boolean modified = disabled == sheet.isEnabled();
sheet.setEnabled(!disabled);
if (modified) {
getDomNodeOrDie().getPage().clearComputedStyles();
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLElement method setInnerText.
/**
* Replaces all child elements of this element with the supplied text value.
* (see https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute)
* @param value the new value for the contents of this element
*/
@JsxSetter
public void setInnerText(final Object value) {
final String valueString;
if (value == null && getBrowserVersion().hasFeature(JS_INNER_TEXT_VALUE_NULL)) {
valueString = null;
} else {
valueString = Context.toString(value);
}
final DomNode domNode = getDomNodeOrDie();
final SgmlPage page = domNode.getPage();
domNode.removeAllChildren();
if (StringUtils.isNotEmpty(valueString)) {
final String[] parts = valueString.split("\\r?\\n");
for (int i = 0; i < parts.length; i++) {
if (i != 0) {
domNode.appendChild(page.createElement(HtmlBreak.TAG_NAME));
}
domNode.appendChild(new DomText(page, parts[i]));
}
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLAnchorElement method setUsername.
/**
* Sets the {@code username} attribute.
* @param username {@code username} attribute
*/
@JsxSetter({ CHROME, EDGE, FF, FF_ESR })
public void setUsername(final String username) {
try {
final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
final String href = anchor.getHrefAttribute();
if (ATTRIBUTE_NOT_DEFINED == href) {
return;
}
final URL url = ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(href);
setUrl(UrlUtils.getUrlWithNewUserName(url, username));
} catch (final MalformedURLException e) {
// ignore
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLAnchorElement method setPassword.
/**
* Sets the {@code password} attribute.
* @param password {@code password} attribute
*/
@JsxSetter({ CHROME, EDGE, FF, FF_ESR })
public void setPassword(final String password) {
try {
final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
final String href = anchor.getHrefAttribute();
if (ATTRIBUTE_NOT_DEFINED == href) {
return;
}
final URL url = ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(href);
setUrl(UrlUtils.getUrlWithNewUserPassword(url, password));
} catch (final MalformedURLException e) {
// ignore
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter in project htmlunit by HtmlUnit.
the class HTMLAnchorElement method setHost.
/**
* Sets the host portion of the link's URL (the '[hostname]:[port]' portion).
* @param host the new host portion of the link's URL
* @throws Exception if an error occurs
* @see <a href="http://msdn.microsoft.com/en-us/library/ms533784.aspx">MSDN Documentation</a>
*/
@JsxSetter
public void setHost(final String host) throws Exception {
final String hostname;
final int port;
final int index = host.indexOf(':');
if (index != -1) {
hostname = host.substring(0, index);
port = Integer.parseInt(host.substring(index + 1));
} else {
hostname = host;
port = -1;
}
final URL url = UrlUtils.getUrlWithNewHostAndPort(getUrl(), hostname, port);
setUrl(url);
}
Aggregations