use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction in project htmlunit by HtmlUnit.
the class HTMLElement method mergeAttributes.
/**
* An IE-only method which copies all custom attributes from the specified source element
* to this element.
* @param source the source element from which to copy the custom attributes
* @param preserveIdentity if {@code false}, the <tt>name</tt> and <tt>id</tt> attributes are not copied
*/
@JsxFunction(IE)
public void mergeAttributes(final HTMLElement source, final Object preserveIdentity) {
final HtmlElement src = source.getDomNodeOrDie();
final HtmlElement target = getDomNodeOrDie();
// Merge ID and name if we aren't preserving identity.
if (preserveIdentity instanceof Boolean && !((Boolean) preserveIdentity).booleanValue()) {
target.setId(src.getId());
target.setAttribute("name", src.getAttributeDirect("name"));
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction in project htmlunit by HtmlUnit.
the class HTMLElement method removeNode.
/**
* Removes this object from the document hierarchy.
* @param removeChildren whether to remove children or no
* @return a reference to the object that is removed
*/
@JsxFunction(IE)
public HTMLElement removeNode(final boolean removeChildren) {
final HTMLElement parent = (HTMLElement) getParentElement();
if (parent != null) {
parent.removeChild(this);
if (!removeChildren) {
final NodeList collection = getChildNodes();
final int length = collection.getLength();
for (int i = 0; i < length; i++) {
final Node object = (Node) collection.item(Integer.valueOf(0));
parent.appendChild(object);
}
}
}
return this;
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction in project htmlunit by HtmlUnit.
the class HTMLElement method setActive.
/**
* Sets the object as active without setting focus to the object.
* @see <a href="http://msdn.microsoft.com/en-us/library/ms536738.aspx">MSDN documentation</a>
*/
@JsxFunction(IE)
public void setActive() {
final Window window = getWindow();
final HTMLDocument document = (HTMLDocument) window.getDocument();
document.setActiveElement(this);
if (window.getWebWindow() == window.getWebWindow().getWebClient().getCurrentWindow()) {
final HtmlElement element = getDomNodeOrDie();
((HtmlPage) element.getPage()).setFocusedElement(element);
}
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction in project htmlunit by HtmlUnit.
the class HTMLMediaElement method play.
/**
* Begins playback of the media.
*
* @return a {@link Promise} which is fulfilled when playback has been started,
* or is rejected if for any reason playback cannot be started
*/
@JsxFunction
public Object play() {
if (getBrowserVersion().hasFeature(JS_PROMISE)) {
final Scriptable scope = ScriptableObject.getTopLevelScope(this);
final LambdaConstructor ctor = (LambdaConstructor) getProperty(scope, "Promise");
final LambdaFunction reject = (LambdaFunction) getProperty(ctor, "reject");
return reject.call(Context.getCurrentContext(), this, ctor, new Object[] { new DOMException("HtmlUnit does not support media play().", DOMException.NOT_FOUND_ERR) });
}
return Undefined.instance;
}
use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction in project htmlunit by HtmlUnit.
the class HTMLFormElement method item.
/**
* Retrieves a form object or an object from an elements collection.
* @param index Integer or String that specifies the object or collection to retrieve.
* If this parameter is an integer, it is the zero-based index of the object.
* If this parameter is a string, all objects with matching name or id properties are retrieved,
* and a collection is returned if more than one match is made
* @param subIndex Optional. Integer that specifies the zero-based index of the object to retrieve
* when a collection is returned
* @return an object or a collection of objects if successful, or null otherwise
*/
@JsxFunction(IE)
public Object item(final Object index, final Object subIndex) {
if (index instanceof Number) {
return getElements().item(index);
}
final String name = Context.toString(index);
final Object response = getWithPreemption(name);
if (subIndex instanceof Number && response instanceof HTMLCollection) {
return ((HTMLCollection) response).item(subIndex);
}
return response;
}
Aggregations