java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.event.EventTarget
org.htmlunit.javascript.host.dom.Node
org.htmlunit.javascript.host.Element
- All Implemented Interfaces:
Serializable,Cloneable,org.htmlunit.corejs.javascript.ConstProperties<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.PropHolder<org.htmlunit.corejs.javascript.Scriptable>,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
HTMLElement,SVGElement
JavaScript host object for
Element.- Author:
- Ahmed Ashour, Marc Guillemot, Sudhan Moghe, Ronald Brill, Frank Danek, Anton Demydenko
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.corejs.javascript.ScriptableObject.DescriptorInfo, org.htmlunit.corejs.javascript.ScriptableObject.KeyComparator, org.htmlunit.corejs.javascript.ScriptableObject.LambdaGetterFunction, org.htmlunit.corejs.javascript.ScriptableObject.LambdaSetterFunction -
Field Summary
Fields inherited from class org.htmlunit.javascript.host.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODEFields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidafter(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeorDOMStringobjects in the children list of this node's parent, just after this node.static voidappend(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeobjects or string objects after the last child of this element.static voidbefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeorDOMStringobjects in the children list of this node's parent, just before this node.static Elementclosest(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Traverses this element and its ancestors until it finds a node that matches the specified CSS selector.protected NamedNodeMapCreates the JS object for theattributesproperty.protected voidcreateEventHandler(String eventName, String attrValue) Creates the event handler function from the attribute value.getAttribute(String attributeName) Returns the value of the specified attribute, ornullif the attribute is not defined.org.htmlunit.corejs.javascript.ScriptableReturns the attribute names of this element as an array of strings.getAttributeNode(String name) Retrieves an attribute node by name.getAttributeNodeNS(String namespaceURI, String localName) Returns the attribute node with the given namespace URI and local name.getAttributeNS(String namespaceURI, String localName) Returns the value of the specified attribute in the given namespace, ornullif the attribute is not defined.Returns the attributes of this XML element.Returns the bounding rectangle of this element relative to the viewport.intReturns the current number of child elements.Returns the child elements of this node.Returns the token list of theclassattribute.Returns the value of theclassattribute.intReturns theclientHeightproperty.intReturns theclientLeftproperty.Returns a collection ofDOMRectobjects that describe the layout of the element's content on screen.intReturns theclientTopproperty.intReturns theclientWidthproperty.Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.getElementsByClassName(String className) Returns all descendant elements that have the specified class name(s).getElementsByTagName(String tagName) Returns all descendant elements with the specified tag name.getElementsByTagNameNS(Object namespaceURI, String localName) Returns a liveHTMLCollectionof elements with the given tag name belonging to the given namespace.Returns the first element child.getHTML()Returns the contents of this node as HTML, ignoring shadow DOM parameters as shadow DOM is not supported.getId()Returns the element ID.Returns theinnerHTMLof this element.protected StringgetInnerHTML(DomNode domNode) Helper forgetInnerHTML, reusable byHTMLTemplateElement.Returns the last element child.Returns the local name of this attribute.Returns the URI that identifies an XML namespace.Returns the next sibling that is an element.org.htmlunit.corejs.javascript.FunctionReturns theonbeforecopyevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonbeforecutevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonbeforepasteevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonsearchevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonwebkitfullscreenchangeevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonwebkitfullscreenerrorevent handler for this element.org.htmlunit.corejs.javascript.FunctionReturns theonwheelevent handler for this element.Returns theouterHTMLof this element, including the element's own tags.Returns the first ancestor that is anElement.Returns the namespace prefix.Returns the previous sibling that is an element.intReturns thescrollHeightfor this element.intReturns thescrollLeftvalue for this element.intReturns thescrollTopvalue for this element.intReturns thescrollWidthfor this element.protected CSSStyleDeclarationgetStyle()Returns the style object for this element.Returns the tag name of this element.booleanhasAttribute(String name) Returnstruewhen an attribute with the given name is specified on this element or has a default value.booleanhasAttributeNS(String namespaceURI, String localName) Returnstrueif the element has an attribute with the given namespace URI and local name.booleanReturns whether this node has any attributes.insertAdjacentElement(String where, Object insertedElement) Inserts the given element at the specified position relative to this element.voidinsertAdjacentHTML(String position, String text) Parses the given text as HTML or XML and inserts the resulting nodes at the specified position.voidinsertAdjacentText(String where, String text) Inserts the given text at the specified position relative to this element.protected final booleanReturns whether thedisplaystyle of this element or any ancestor isnone.protected booleanReturns whether the end tag is forbidden for this element.voidCreates an instance of this object.static booleanmatches(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string.static voidmoveBefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Moves a given node inside this element as a direct child, before a given reference node.static booleanmozMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string.static voidprepend(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeobjects or string objects before the first child of this element.protected final voidprintChildren(StringBuilder builder, DomNode node, boolean html) Serializes the children of the given node to the provided builder.protected voidprintNode(StringBuilder builder, DomNode node, boolean html) querySelector(String selectors) Returns the first descendant element that matches the specified CSS selector, ornullif no matches are found.querySelectorAll(String selectors) Returns a staticNodeListof all descendant elements matching the given CSS selector(s).voidReleases mouse capture from the object in the current document.voidremove()Removes the DOM node from its parent.voidremoveAttribute(String name) Removes the attribute with the specified name.voidremoveAttributeNode(Attr attribute) Removes the specified attribute node from this element.voidremoveAttributeNS(String namespaceURI, String localName) Removes the attribute with the given namespace URI and local name.static voidreplaceChildren(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces the existing children of this element with a specified new set of children.static voidreplaceWith(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces this node with a set ofNodeorDOMStringobjects.voidscroll(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls to a particular set of coordinates inside this element.voidscrollBy(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls the element by the given amount.voidScrolls the element into the visible area of the browser window.voidScrolls the element into the visible area if needed.voidscrollTo(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls to a particular set of coordinates inside this element.voidsetAttribute(String name, String value) Sets the specified attribute to the given value.setAttributeNode(Attr newAtt) Sets the attribute node for the specified attribute, replacing the existing node if present.voidsetAttributeNS(String namespaceURI, String qualifiedName, String value) Sets the attribute with the given namespace URI and qualified name to the given value.voidsetCapture(boolean retargetToElement) Sets mouse capture to the object that belongs to the current document.voidsetClassName_js(String className) Sets theclassattribute for this element.voidsetDomNode(DomNode domNode) Sets the DOM node that corresponds to this JavaScript object.voidSets the ID of this element.voidsetInnerHTML(Object value) Replaces all child elements of this element with the supplied HTML value.voidsetOnbeforecopy(Object onbeforecopy) Sets theonbeforecopyevent handler for this element.voidsetOnbeforecut(Object onbeforecut) Sets theonbeforecutevent handler for this element.voidsetOnbeforepaste(Object onbeforepaste) Sets theonbeforepasteevent handler for this element.voidsetOnsearch(Object onsearch) Sets theonsearchevent handler for this element.voidsetOnwebkitfullscreenchange(Object onwebkitfullscreenchange) Sets theonwebkitfullscreenchangeevent handler for this element.voidsetOnwebkitfullscreenerror(Object onwebkitfullscreenerror) Sets theonwebkitfullscreenerrorevent handler for this element.voidsetOnwheel(Object onwheel) Sets theonwheelevent handler for this element.voidsetOuterHTML(Object value) Replaces this element (including all child elements) with the supplied HTML value.voidsetScrollLeft(int scroll) Sets thescrollLeftvalue for this element.voidsetScrollTop(int scroll) Sets thescrollTopvalue for this element.protected voidSets the CSS text for this element's inline style.booleantoggleAttribute(String name, Object force) Toggles a Boolean attribute on this element.static booleanwebkitMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string.Methods inherited from class org.htmlunit.javascript.host.dom.Node
after, append, appendChild, before, cloneNode, compareDocumentPosition, contains, getBaseURI, getChildNodes, getFirstChild, getJavaScriptNode, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParent, getParentNode, getPreviousSibling, getRootNode, getTextContent, hasChildNodes, insertBefore, insertBeforeImpl, isEqualNode, isSameNode, lookupPrefix, normalize, prepend, removeChild, replaceChild, replaceChildren, replaceWith, setNodeValue, setTextContentMethods inherited from class org.htmlunit.javascript.host.event.EventTarget
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerMethods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Constructor Details
-
Element
public Element()
-
-
Method Details
-
jsConstructor
public void jsConstructor()Creates an instance of this object.- Overrides:
jsConstructorin classNode
-
setDomNode
Sets the DOM node that corresponds to this JavaScript object.- Overrides:
setDomNodein classHtmlUnitScriptable- Parameters:
domNode- the DOM node
-
createEventHandler
Creates the event handler function from the attribute value.- Parameters:
eventName- the event name (e.g.onclick)attrValue- the attribute value
-
getTagName
Returns the tag name of this element.- Returns:
- the tag name
-
getAttributes
Returns the attributes of this XML element.- Overrides:
getAttributesin classNode- Returns:
- the attributes of this XML element
- See Also:
-
createAttributesObject
Creates the JS object for theattributesproperty. This object will be cached.- Returns:
- the JS object
-
getAttribute
Returns the value of the specified attribute, ornullif the attribute is not defined.- Parameters:
attributeName- the name of the attribute to retrieve- Returns:
- the value of the specified attribute, or
nullif not defined
-
setAttribute
Sets the specified attribute to the given value.- Parameters:
name- the name of the attribute to setvalue- the value to set the attribute to
-
getElementsByTagName
Returns all descendant elements with the specified tag name.- Parameters:
tagName- the tag name to search for- Returns:
- all descendant elements with the specified tag name
-
getAttributeNode
Retrieves an attribute node by name.- Parameters:
name- the name of the attribute to retrieve- Returns:
- the
Attrnode with the specified name, ornullif there is no such attribute
-
getElementsByTagNameNS
Returns a liveHTMLCollectionof elements with the given tag name belonging to the given namespace.- Parameters:
namespaceURI- the namespace URI of elements to look forlocalName- the local name of elements to look for, or"*"to match all elements- Returns:
- a live
HTMLCollectionof found elements in document order
-
hasAttribute
Returnstruewhen an attribute with the given name is specified on this element or has a default value.- Parameters:
name- the name of the attribute to look for- Returns:
trueif the attribute exists or has a default value
-
hasAttributes
public boolean hasAttributes()Returns whether this node has any attributes.- Overrides:
hasAttributesin classNode- Returns:
trueif this node has one or more attributes
-
getDomNodeOrDie
Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.- Overrides:
getDomNodeOrDiein classHtmlUnitScriptable- Returns:
- the DOM node
-
removeAttribute
Removes the attribute with the specified name.- Parameters:
name- the name of the attribute to remove
-
getBoundingClientRect
Returns the bounding rectangle of this element relative to the viewport.- Returns:
- a
DOMRectobject describing the element's size and position - See Also:
-
getChildElementCount
public int getChildElementCount()Returns the current number of child elements.- Overrides:
getChildElementCountin classNode- Returns:
- the child element count
-
getFirstElementChild
Returns the first element child.- Overrides:
getFirstElementChildin classNode- Returns:
- the first element child
-
getLastElementChild
Returns the last element child.- Overrides:
getLastElementChildin classNode- Returns:
- the last element child
-
getNextElementSibling
Returns the next sibling that is an element.- Returns:
- the next element sibling, or
nullif none
-
getPreviousElementSibling
Returns the previous sibling that is an element.- Returns:
- the previous element sibling, or
nullif none
-
getParentElement
- Overrides:
getParentElementin classNode- Returns:
- the parent element
- See Also:
-
getChildren
Returns the child elements of this node.- Overrides:
getChildrenin classNode- Returns:
- a live collection of this node's child elements
- See Also:
-
getClassList
Returns the token list of theclassattribute.- Returns:
- the token list of the
classattribute
-
getAttributeNS
Returns the value of the specified attribute in the given namespace, ornullif the attribute is not defined.- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to retrieve- Returns:
- the attribute value, or
nullif not found
-
hasAttributeNS
Returnstrueif the element has an attribute with the given namespace URI and local name.- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to look for- Returns:
trueif the attribute exists
-
setAttributeNS
Sets the attribute with the given namespace URI and qualified name to the given value.- Parameters:
namespaceURI- the namespace URIqualifiedName- the qualified name of the attributevalue- the new attribute value
-
removeAttributeNS
Removes the attribute with the given namespace URI and local name.- Parameters:
namespaceURI- the namespace URI of the attribute to removelocalName- the local name of the attribute to remove
-
setAttributeNode
Sets the attribute node for the specified attribute, replacing the existing node if present.- Parameters:
newAtt- the attribute node to set- Returns:
- the replaced attribute node, if any
-
querySelectorAll
Returns a staticNodeListof all descendant elements matching the given CSS selector(s).- Parameters:
selectors- the CSS selector(s)- Returns:
- the static node list of matching elements
-
querySelector
Returns the first descendant element that matches the specified CSS selector, ornullif no matches are found.- Parameters:
selectors- the CSS selector(s)- Returns:
- the first matching element, or
null
-
getClassName_js
Returns the value of theclassattribute.- Returns:
- the class name
-
setClassName_js
Sets theclassattribute for this element.- Parameters:
className- the new class name
-
getClientHeight
public int getClientHeight()Returns theclientHeightproperty.- Returns:
- the
clientHeightproperty
-
getClientWidth
public int getClientWidth()Returns theclientWidthproperty.- Returns:
- the
clientWidthproperty
-
getClientLeft
public int getClientLeft()Returns theclientLeftproperty.- Returns:
- the
clientLeftproperty
-
getClientTop
public int getClientTop()Returns theclientTopproperty.- Returns:
- the
clientTopproperty
-
getAttributeNodeNS
Returns the attribute node with the given namespace URI and local name.- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to retrieve- Returns:
- the specified attribute node, or
nullif not found
-
getElementsByClassName
Returns all descendant elements that have the specified class name(s).- Parameters:
className- the class name(s) to search for (space-separated)- Returns:
- all descendant elements with the specified class name(s)
-
getClientRects
Returns a collection ofDOMRectobjects that describe the layout of the element's content on screen. Each rectangle represents one line of the element's content.- Returns:
- a
DOMRectListdescribing the element's line boxes
-
getAttributeNames
public org.htmlunit.corejs.javascript.Scriptable getAttributeNames()Returns the attribute names of this element as an array of strings. Returns an empty array if the element has no attributes.- Returns:
- the attribute names as an array
-
isDisplayNone
protected final boolean isDisplayNone()Returns whether thedisplaystyle of this element or any ancestor isnone.- Returns:
trueif the element or any ancestor hasdisplay: none
-
insertAdjacentElement
Inserts the given element at the specified position relative to this element.- Parameters:
where- specifies where to insert the element; one ofbeforebegin,afterbegin,beforeend, orafterend(case-insensitive)insertedElement- the element to insert- Returns:
- the inserted element
- See Also:
-
insertAdjacentText
Inserts the given text at the specified position relative to this element.- Parameters:
where- specifies where to insert the text; one ofbeforebegin,afterbegin,beforeend, orafterend(case-insensitive)text- the text to insert- See Also:
-
insertAdjacentHTML
Parses the given text as HTML or XML and inserts the resulting nodes at the specified position.- Parameters:
position- specifies where to insert the nodes; one ofbeforebegin,afterbegin,beforeend, orafterend(case-insensitive)text- the HTML or XML text to parse and insert- See Also:
-
moveBefore
public static void moveBefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Moves a given node inside this element as a direct child, before a given reference node.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function
-
getHTML
Returns the contents of this node as HTML, ignoring shadow DOM parameters as shadow DOM is not supported.- Returns:
- the contents of this node as HTML
-
getInnerHTML
Returns theinnerHTMLof this element.- Returns:
- the contents of this node as HTML
-
setInnerHTML
Replaces all child elements of this element with the supplied HTML value.- Parameters:
value- the new HTML content for this element
-
getInnerHTML
Helper forgetInnerHTML, reusable byHTMLTemplateElement.- Parameters:
domNode- the node to serialize- Returns:
- the contents of this node as HTML
-
getOuterHTML
Returns theouterHTMLof this element, including the element's own tags.- Returns:
- the contents of this node as HTML, including the opening and closing tags
- See Also:
-
setOuterHTML
Replaces this element (including all child elements) with the supplied HTML value.- Parameters:
value- the new HTML to replace this element
-
printChildren
Serializes the children of the given node to the provided builder.- Parameters:
builder- the builder to write tonode- the node whose children are to be serializedhtml- whether to use HTML serialization
-
printNode
-
isEndTagForbidden
protected boolean isEndTagForbidden()Returns whether the end tag is forbidden for this element.- Returns:
- whether the end tag is forbidden
- See Also:
-
getId
Returns the element ID.- Returns:
- the ID of this element
-
setId
Sets the ID of this element.- Parameters:
newId- the new ID value for this element
-
removeAttributeNode
Removes the specified attribute node from this element.- Parameters:
attribute- the attribute node to remove
-
getScrollTop
public int getScrollTop()Returns thescrollTopvalue for this element.- Returns:
- the
scrollTopvalue - See Also:
-
setScrollTop
public void setScrollTop(int scroll) Sets thescrollTopvalue for this element.- Parameters:
scroll- the newscrollTopvalue
-
getScrollLeft
public int getScrollLeft()Returns thescrollLeftvalue for this element.- Returns:
- the
scrollLeftvalue - See Also:
-
setScrollLeft
public void setScrollLeft(int scroll) Sets thescrollLeftvalue for this element.- Parameters:
scroll- the newscrollLeftvalue
-
getScrollHeight
public int getScrollHeight()Returns thescrollHeightfor this element. Currently returns the same value asgetClientHeight().- Returns:
- the scroll height
- See Also:
-
getScrollWidth
public int getScrollWidth()Returns thescrollWidthfor this element. Currently returns the same value asgetClientWidth().- Returns:
- the scroll width
- See Also:
-
getStyle
Returns the style object for this element.- Returns:
- the style object for this element
-
setStyle
Sets the CSS text for this element's inline style.- Parameters:
style- the new CSS style text
-
scroll
public void scroll(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls to a particular set of coordinates inside this element.- Parameters:
x- the horizontal pixel value to scroll toy- the vertical pixel value to scroll to
-
scrollBy
public void scrollBy(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls the element by the given amount.- Parameters:
x- the horizontal pixel value to scroll byy- the vertical pixel value to scroll by
-
scrollTo
public void scrollTo(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y) Scrolls to a particular set of coordinates inside this element.- Parameters:
x- the horizontal pixel value to scroll toy- the vertical pixel value to scroll to
-
scrollIntoView
public void scrollIntoView()Scrolls the element into the visible area of the browser window. This implementation triggers the scroll event but does not actually scroll (headless environment). -
scrollIntoViewIfNeeded
public void scrollIntoViewIfNeeded()Scrolls the element into the visible area if needed. This is a no-op implementation. -
getPrefix
Returns the namespace prefix. -
getLocalName
Returns the local name of this attribute.- Overrides:
getLocalNamein classNode- Returns:
- the local name of this attribute
-
getNamespaceURI
Returns the URI that identifies an XML namespace.- Overrides:
getNamespaceURIin classNode- Returns:
- the URI that identifies an XML namespace
-
getOnbeforecopy
public org.htmlunit.corejs.javascript.Function getOnbeforecopy()Returns theonbeforecopyevent handler for this element.- Returns:
- the
onbeforecopyevent handler for this element
-
setOnbeforecopy
Sets theonbeforecopyevent handler for this element.- Parameters:
onbeforecopy- theonbeforecopyevent handler for this element
-
getOnbeforecut
public org.htmlunit.corejs.javascript.Function getOnbeforecut()Returns theonbeforecutevent handler for this element.- Returns:
- the
onbeforecutevent handler for this element
-
setOnbeforecut
Sets theonbeforecutevent handler for this element.- Parameters:
onbeforecut- theonbeforecutevent handler for this element
-
getOnbeforepaste
public org.htmlunit.corejs.javascript.Function getOnbeforepaste()Returns theonbeforepasteevent handler for this element.- Returns:
- the
onbeforepasteevent handler for this element
-
setOnbeforepaste
Sets theonbeforepasteevent handler for this element.- Parameters:
onbeforepaste- theonbeforepasteevent handler for this element
-
getOnsearch
public org.htmlunit.corejs.javascript.Function getOnsearch()Returns theonsearchevent handler for this element.- Returns:
- the
onsearchevent handler for this element
-
setOnsearch
Sets theonsearchevent handler for this element.- Parameters:
onsearch- theonsearchevent handler for this element
-
getOnwebkitfullscreenchange
public org.htmlunit.corejs.javascript.Function getOnwebkitfullscreenchange()Returns theonwebkitfullscreenchangeevent handler for this element.- Returns:
- the
onwebkitfullscreenchangeevent handler for this element
-
setOnwebkitfullscreenchange
Sets theonwebkitfullscreenchangeevent handler for this element.- Parameters:
onwebkitfullscreenchange- theonwebkitfullscreenchangeevent handler for this element
-
getOnwebkitfullscreenerror
public org.htmlunit.corejs.javascript.Function getOnwebkitfullscreenerror()Returns theonwebkitfullscreenerrorevent handler for this element.- Returns:
- the
onwebkitfullscreenerrorevent handler for this element
-
setOnwebkitfullscreenerror
Sets theonwebkitfullscreenerrorevent handler for this element.- Parameters:
onwebkitfullscreenerror- theonwebkitfullscreenerrorevent handler for this element
-
getOnwheel
public org.htmlunit.corejs.javascript.Function getOnwheel()Returns theonwheelevent handler for this element.- Returns:
- the
onwheelevent handler for this element
-
setOnwheel
Sets theonwheelevent handler for this element.- Parameters:
onwheel- theonwheelevent handler for this element
-
remove
public void remove()Removes the DOM node from its parent. -
setCapture
public void setCapture(boolean retargetToElement) Sets mouse capture to the object that belongs to the current document. This is a mock implementation.- Parameters:
retargetToElement- iftrue, all events are targeted directly to this element; iffalse, events can also fire at descendants of this element
-
releaseCapture
public void releaseCapture()Releases mouse capture from the object in the current document. This is a mock implementation. -
before
public static void before(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeorDOMStringobjects in the children list of this node's parent, just before this node.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
after
public static void after(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeorDOMStringobjects in the children list of this node's parent, just after this node.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
replaceWith
public static void replaceWith(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces this node with a set ofNodeorDOMStringobjects.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
matches
public static boolean matches(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
trueif the element matches the selector
-
mozMatchesSelector
public static boolean mozMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string. Firefox-specific alias formatches(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, org.htmlunit.corejs.javascript.Scriptable, java.lang.Object[], org.htmlunit.corejs.javascript.Function).- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
trueif the element matches the selector
-
webkitMatchesSelector
public static boolean webkitMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Returnstrueif the element would be selected by the specified CSS selector string. WebKit-specific alias formatches(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.VarScope, org.htmlunit.corejs.javascript.Scriptable, java.lang.Object[], org.htmlunit.corejs.javascript.Function).- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
trueif the element matches the selector
-
closest
public static Element closest(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Traverses this element and its ancestors until it finds a node that matches the specified CSS selector.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function- Returns:
- the closest matching ancestor element, or
nullif none found
-
toggleAttribute
Toggles a Boolean attribute on this element. Ifforceistrue, adds the attribute. Ifforceisfalse, removes the attribute. Ifforceis not specified, the attribute is toggled.- Parameters:
name- the name of the attribute to toggle; automatically converted to lower-case for HTML elementsforce- iftrue, adds the attribute; iffalse, removes it- Returns:
trueif the attribute is present after the call,falseotherwise- See Also:
-
append
public static void append(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeobjects or string objects after the last child of this element. String objects are inserted as equivalentTextnodes.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
prepend
public static void prepend(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Inserts a set ofNodeobjects or string objects before the first child of this element. String objects are inserted as equivalentTextnodes.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
replaceChildren
public static void replaceChildren(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces the existing children of this element with a specified new set of children. These can be string orNodeobjects.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-