Package org.htmlunit.javascript.host
Class Element
- java.lang.Object
-
- 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:
java.io.Serializable,java.lang.Cloneable,org.htmlunit.corejs.javascript.ConstProperties,org.htmlunit.corejs.javascript.debug.DebuggableObject,org.htmlunit.corejs.javascript.Scriptable,org.htmlunit.corejs.javascript.SymbolScriptable
- Direct Known Subclasses:
HTMLElement,SVGElement
public class Element extends Node
A JavaScript object forElement.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private NamedNodeMapattributes_private static java.util.regex.PatternCLASS_NAMES_SPLIT_PATTERNprivate java.util.Map<java.lang.String,HTMLCollection>elementsByTagName_(package private) static java.lang.StringPOSITION_AFTER_BEGIN(package private) static java.lang.StringPOSITION_AFTER_END(package private) static java.lang.StringPOSITION_BEFORE_BEGIN(package private) static java.lang.StringPOSITION_BEFORE_ENDprivate static java.util.regex.PatternPRINT_NODE_PATTERNprivate static java.util.regex.PatternPRINT_NODE_QUOTE_PATTERNprivate intscrollLeft_private intscrollTop_private CSSStyleDeclarationstyle_-
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_NODE
-
-
Constructor Summary
Constructors Constructor Description Element()Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidafter(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode.static voidappend(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node objects or string objects after the last child of the Element.static voidbefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode.static Elementclosest(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)protected NamedNodeMapcreateAttributesObject()Creates the JS object for the property attributes.protected voidcreateEventHandler(java.lang.String eventName, java.lang.String attrValue)Create the event handler function from the attribute value.java.lang.StringgetAttribute(java.lang.String attributeName)HtmlUnitScriptablegetAttributeNode(java.lang.String name)Retrieves an attribute node by name.HtmlUnitScriptablegetAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)Returns the specified attribute.java.lang.StringgetAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Gets the specified attribute.NamedNodeMapgetAttributes()Returns the attributes of this XML element.ClientRectgetBoundingClientRect()Retrieves an object that specifies the bounds of a collection of TextRectangle objects.intgetChildElementCount()Returns the current number of child elements.HTMLCollectiongetChildren()Gets the children of the current node.DOMTokenListgetClassList()Gets the token list of class attribute.java.lang.ObjectgetClassName_js()Returns the class defined for this element.intgetClientHeight()Returns theclientHeightattribute.intgetClientLeft()Returns theclientLeftattribute.ClientRectListgetClientRects()Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client.intgetClientTop()ReturnsclientTopattribute.intgetClientWidth()Returns theclientWidthattribute.DomElementgetDomNodeOrDie()Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.HTMLCollectiongetElementsByClassName(java.lang.String className)Returns all the descendant elements with the specified class.HTMLCollectiongetElementsByTagName(java.lang.String tagName)Returns all the descendant elements with the specified tag name.java.lang.ObjectgetElementsByTagNameNS(java.lang.Object namespaceURI, java.lang.String localName)Returns a list of elements with the given tag name belonging to the given namespace.ElementgetFirstElementChild()Returns the first element child.java.lang.StringgetId()Returns the element ID.java.lang.StringgetInnerHTML()Gets theinnerHTMLattribute.protected java.lang.StringgetInnerHTML(DomNode domNode)Helper for getInnerHtml (to be reuses bei HTMLTemplate.private java.lang.Object[]getInsertAdjacentLocation(java.lang.String where)Returns where and how to add the new node.ElementgetLastElementChild()Returns the last element child.java.lang.ObjectgetLocalName()Returns the local name of this attribute.java.lang.ObjectgetNamespaceURI()Returns the URI that identifies an XML namespace.ElementgetNextElementSibling()Returns the next element sibling.org.htmlunit.corejs.javascript.FunctiongetOnbeforecopy()Returns theonbeforecopyevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnbeforecut()Returns theonbeforecutevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnbeforepaste()Returns theonbeforepasteevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnsearch()Returns theonsearchevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnwebkitfullscreenchange()Returns theonwebkitfullscreenchangeevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnwebkitfullscreenerror()Returns theonwebkitfullscreenerrorevent handler for this element.org.htmlunit.corejs.javascript.FunctiongetOnwheel()Returns theonwheelevent handler for this element.java.lang.StringgetOuterHTML()Gets the outerHTML of the node.ElementgetParentElement()Gets the first ancestor instance ofElement.java.lang.ObjectgetPrefix()Returns the namespace prefix.ElementgetPreviousElementSibling()Returns the previous element sibling.intgetScrollHeight()Gets the scrollHeight for this element.intgetScrollLeft()Gets the scrollLeft value for this element.intgetScrollTop()Gets the scrollTop value for this element.intgetScrollWidth()Gets the scrollWidth for this element.protected CSSStyleDeclarationgetStyle()Returns the style object for this element.java.lang.StringgetTagName()Returns the tag name of this element.booleanhasAttribute(java.lang.String name)Returns true when an attribute with a given name is specified on this element or has a default value.booleanhasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Test for attribute.booleanhasAttributes()Returns true when the current element has any attributes or not.java.lang.StringinnerHTML()ThegetInnerHTMLfunction.java.lang.ObjectinsertAdjacentElement(java.lang.String where, java.lang.Object insertedElement)Inserts the given element into the element at the location.voidinsertAdjacentHTML(java.lang.String position, java.lang.String text)Parses the given text as HTML or XML and inserts the resulting nodes into the tree in the position given by the position argument.voidinsertAdjacentText(java.lang.String where, java.lang.String text)Inserts the given text into the element at the specified location.protected booleanisDisplayNone()Returns whether thedisplayisnoneor not.protected booleanisEndTagForbidden()Returns whether the end tag is forbidden or not.voidjsConstructor()JavaScript constructor.static booleanmatches(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.static booleanmozMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.private static voidparseHtmlSnippet(DomNode target, java.lang.String source)Parses the specified HTML source code, appending the resulting content at the specified target location.static voidprepend(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node objects or string objects before the first child of the Element.protected voidprintChildren(java.lang.StringBuilder builder, DomNode node, boolean html)Helper for getting code back from nodes.protected voidprintNode(java.lang.StringBuilder builder, DomNode node, boolean html)NodequerySelector(java.lang.String selectors)Returns the first element within the document that matches the specified group of selectors.NodeListquerySelectorAll(java.lang.String selectors)Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings.voidreleaseCapture()Mock for the moment.voidremove()Removes the DOM node from its parent.voidremoveAttribute(java.lang.String name)Removes the specified attribute.voidremoveAttributeNode(Attr attribute)Removes the specified attribute.voidremoveAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Removes the specified attribute.static voidreplaceChildren(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Replaces the existing children of a Node with a specified new set of children.static voidreplaceWith(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Replaces the node with a set of Node or DOMString objects.voidscroll()Implement thescroll()JavaScript function but don't actually do anything.voidscrollBy()Implement thescrollBy()JavaScript function but don't actually do anything.voidscrollIntoView()Implement thescrollIntoView()JavaScript function but don't actually do anything.voidscrollIntoViewIfNeeded()Implement thescrollIntoViewIfNeeded()JavaScript function but don't actually do anything.voidscrollTo()Implement thescrollTo()JavaScript function but don't actually do anything.voidsetAttribute(java.lang.String name, java.lang.String value)Sets an attribute.AttrsetAttributeNode(Attr newAtt)Sets the attribute node for the specified attribute.voidsetAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)Sets the specified attribute.voidsetCapture(boolean retargetToElement)Mock for the moment.voidsetClassName_js(java.lang.String className)Sets the class attribute for this element.voidsetDomNode(DomNode domNode)Sets the DOM node that corresponds to this JavaScript object.voidsetId(java.lang.String newId)Sets the id value for this element.voidsetInnerHTML(java.lang.Object value)Replaces all child elements of this element with the supplied value.voidsetOnbeforecopy(java.lang.Object onbeforecopy)Sets theonbeforecopyevent handler for this element.voidsetOnbeforecut(java.lang.Object onbeforecut)Sets theonbeforecutevent handler for this element.voidsetOnbeforepaste(java.lang.Object onbeforepaste)Sets theonbeforepasteevent handler for this element.voidsetOnsearch(java.lang.Object onsearch)Sets theonsearchevent handler for this element.voidsetOnwebkitfullscreenchange(java.lang.Object onwebkitfullscreenchange)Sets theonwebkitfullscreenchangeevent handler for this element.voidsetOnwebkitfullscreenerror(java.lang.Object onwebkitfullscreenerror)Sets theonwebkitfullscreenerrorevent handler for this element.voidsetOnwheel(java.lang.Object onwheel)Sets theonwheelevent handler for this element.voidsetOuterHTML(java.lang.Object value)Replaces this element (including all child elements) with the supplied value.voidsetScrollLeft(int scroll)Sets the scrollLeft value for this element.voidsetScrollTop(int scroll)Sets the scrollTop value for this element.protected voidsetStyle(java.lang.String style)Sets the styles for this element.booleantoggleAttribute(java.lang.String name, java.lang.Object force)ThetoggleAttribute()method of the Element interface toggles a Boolean attribute (removing it if it is present and adding it if it is not present) on the given element.static booleanwebkitMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.-
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, normalize, prepend, removeChild, replaceChild, replaceChildren, replaceWith, setNodeValue, setTextContent
-
Methods inherited from class org.htmlunit.javascript.host.event.EventTarget
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandler
-
Methods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getWindow, getWindow, getWithPreemption, has, hasInstance, initParentScope, makeScriptableFor, put, setClassName, setDomNode, setParentScope, setupPromise, setupRejectedPromise
-
Methods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkPropertyChange, checkPropertyDefinition, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureSymbolScriptable, get, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, has, has, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, preventExtensions, put, put, putConst, putConstProperty, putProperty, putProperty, putProperty, querySlot, redefineProperty, sameValue, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setPrototype, size
-
-
-
-
Field Detail
-
POSITION_BEFORE_BEGIN
static final java.lang.String POSITION_BEFORE_BEGIN
- See Also:
- Constant Field Values
-
POSITION_AFTER_BEGIN
static final java.lang.String POSITION_AFTER_BEGIN
- See Also:
- Constant Field Values
-
POSITION_BEFORE_END
static final java.lang.String POSITION_BEFORE_END
- See Also:
- Constant Field Values
-
POSITION_AFTER_END
static final java.lang.String POSITION_AFTER_END
- See Also:
- Constant Field Values
-
CLASS_NAMES_SPLIT_PATTERN
private static final java.util.regex.Pattern CLASS_NAMES_SPLIT_PATTERN
-
PRINT_NODE_PATTERN
private static final java.util.regex.Pattern PRINT_NODE_PATTERN
-
PRINT_NODE_QUOTE_PATTERN
private static final java.util.regex.Pattern PRINT_NODE_QUOTE_PATTERN
-
attributes_
private NamedNodeMap attributes_
-
elementsByTagName_
private java.util.Map<java.lang.String,HTMLCollection> elementsByTagName_
-
scrollLeft_
private int scrollLeft_
-
scrollTop_
private int scrollTop_
-
style_
private CSSStyleDeclaration style_
-
-
Method Detail
-
jsConstructor
public void jsConstructor()
JavaScript constructor.- Overrides:
jsConstructorin classNode
-
setDomNode
public void setDomNode(DomNode domNode)
Sets the DOM node that corresponds to this JavaScript object.- Overrides:
setDomNodein classHtmlUnitScriptable- Parameters:
domNode- the DOM node
-
createEventHandler
protected void createEventHandler(java.lang.String eventName, java.lang.String attrValue)Create the event handler function from the attribute value.- Parameters:
eventName- the event name (ex: "onclick")attrValue- the attribute value
-
getTagName
public java.lang.String getTagName()
Returns the tag name of this element.- Returns:
- the tag name
-
getAttributes
public NamedNodeMap getAttributes()
Returns the attributes of this XML element.- Overrides:
getAttributesin classNode- Returns:
- the attributes of this XML element
- See Also:
- Gecko DOM Reference
-
createAttributesObject
protected NamedNodeMap createAttributesObject()
Creates the JS object for the property attributes. This object will the be cached.- Returns:
- the JS object
-
getAttribute
public java.lang.String getAttribute(java.lang.String attributeName)
- Parameters:
attributeName- attribute name- Returns:
- the value of the specified attribute,
nullif the attribute is not defined
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.String value)Sets an attribute.- Parameters:
name- Name of the attribute to setvalue- Value to set the attribute to
-
getElementsByTagName
public HTMLCollection getElementsByTagName(java.lang.String tagName)
Returns all the descendant elements with the specified tag name.- Parameters:
tagName- the name to search for- Returns:
- all the descendant elements with the specified tag name
-
getAttributeNode
public HtmlUnitScriptable getAttributeNode(java.lang.String name)
Retrieves an attribute node by name.- Parameters:
name- the name of the attribute to retrieve- Returns:
- the XMLAttr node with the specified name or
nullif there is no such attribute
-
getElementsByTagNameNS
public java.lang.Object getElementsByTagNameNS(java.lang.Object namespaceURI, java.lang.String localName)Returns a list of elements with the given tag name belonging to the given namespace.- Parameters:
namespaceURI- the namespace URI of elements to look forlocalName- is either the local name of elements to look for or the special value "*", which matches all elements.- Returns:
- a live NodeList of found elements in the order they appear in the tree
-
hasAttribute
public boolean hasAttribute(java.lang.String name)
Returns true when an attribute with a given name is specified on this element or has a default value. See also the DOM reference- Parameters:
name- the name of the attribute to look for- Returns:
- true if an attribute with the given name is specified on this element or has a default value
-
hasAttributes
public boolean hasAttributes()
Returns true when the current element has any attributes or not.- Overrides:
hasAttributesin classNode- Returns:
- true if an attribute is specified on this element
-
getDomNodeOrDie
public DomElement 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
public void removeAttribute(java.lang.String name)
Removes the specified attribute.- Parameters:
name- the name of the attribute to remove
-
getBoundingClientRect
public ClientRect getBoundingClientRect()
Retrieves an object that specifies the bounds of a collection of TextRectangle objects.- Returns:
- an object that specifies the bounds of a collection of TextRectangle objects
- See Also:
- MSDN doc
-
getChildElementCount
public int getChildElementCount()
Returns the current number of child elements.- Overrides:
getChildElementCountin classNode- Returns:
- the child element count
-
getFirstElementChild
public Element getFirstElementChild()
Returns the first element child.- Overrides:
getFirstElementChildin classNode- Returns:
- the first element child
-
getLastElementChild
public Element getLastElementChild()
Returns the last element child.- Overrides:
getLastElementChildin classNode- Returns:
- the last element child
-
getNextElementSibling
public Element getNextElementSibling()
Returns the next element sibling.- Returns:
- the next element sibling
-
getPreviousElementSibling
public Element getPreviousElementSibling()
Returns the previous element sibling.- Returns:
- the previous element sibling
-
getParentElement
public Element getParentElement()
Gets the first ancestor instance ofElement. It is mostly identical toNode.getParent()except that it skips nonElementnodes.- Overrides:
getParentElementin classNode- Returns:
- the parent element
- See Also:
Node.getParent()
-
getChildren
public HTMLCollection getChildren()
Gets the children of the current node.- Overrides:
getChildrenin classNode- Returns:
- the child at the given position
- See Also:
- MSDN documentation
-
getClassList
public DOMTokenList getClassList()
Gets the token list of class attribute.- Returns:
- the token list of class attribute
-
getAttributeNS
public java.lang.String getAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Gets the specified attribute.- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to look for- Returns:
- the value of the specified attribute,
nullif the attribute is not defined
-
hasAttributeNS
public boolean hasAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Test for attribute. See also the DOM reference- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to look for- Returns:
trueif the node has this attribute
-
setAttributeNS
public void setAttributeNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String value)Sets the specified attribute.- Parameters:
namespaceURI- the namespace URIqualifiedName- the qualified name of the attribute to look forvalue- the new attribute value
-
removeAttributeNS
public void removeAttributeNS(java.lang.String namespaceURI, java.lang.String localName)Removes the specified attribute.- Parameters:
namespaceURI- the namespace URI of the attribute to removelocalName- the local name of the attribute to remove
-
setAttributeNode
public Attr setAttributeNode(Attr newAtt)
Sets the attribute node for the specified attribute.- Parameters:
newAtt- the attribute to set- Returns:
- the replaced attribute node, if any
-
querySelectorAll
public NodeList querySelectorAll(java.lang.String selectors)
Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings. The NodeList object returned by the querySelectorAll() method must be static, not live.- Parameters:
selectors- the selectors- Returns:
- the static node list
-
querySelector
public Node querySelector(java.lang.String selectors)
Returns the first element within the document that matches the specified group of selectors.- Parameters:
selectors- the selectors- Returns:
- null if no matches are found; otherwise, it returns the first matching element
-
getClassName_js
public java.lang.Object getClassName_js()
Returns the class defined for this element.- Returns:
- the class name
-
setClassName_js
public void setClassName_js(java.lang.String className)
Sets the class attribute for this element.- Parameters:
className- the new class name
-
getClientHeight
public int getClientHeight()
Returns theclientHeightattribute.- Returns:
- the
clientHeightattribute
-
getClientWidth
public int getClientWidth()
Returns theclientWidthattribute.- Returns:
- the
clientWidthattribute
-
getClientLeft
public int getClientLeft()
Returns theclientLeftattribute.- Returns:
- the
clientLeftattribute
-
getClientTop
public int getClientTop()
ReturnsclientTopattribute.- Returns:
- the
clientTopattribute
-
getAttributeNodeNS
public HtmlUnitScriptable getAttributeNodeNS(java.lang.String namespaceURI, java.lang.String localName)
Returns the specified attribute.- Parameters:
namespaceURI- the namespace URIlocalName- the local name of the attribute to look for- Returns:
- the specified attribute,
nullif the attribute is not defined
-
getElementsByClassName
public HTMLCollection getElementsByClassName(java.lang.String className)
Returns all the descendant elements with the specified class.- Parameters:
className- the name to search for- Returns:
- all the descendant elements with the specified class name
-
getClientRects
public ClientRectList getClientRects()
Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client. Each rectangle describes a single line.- Returns:
- a collection of rectangles that describes the layout of the contents
-
isDisplayNone
protected final boolean isDisplayNone()
Returns whether thedisplayisnoneor not.- Returns:
- whether the
displayisnoneor not
-
insertAdjacentElement
public java.lang.Object insertAdjacentElement(java.lang.String where, java.lang.Object insertedElement)Inserts the given element into the element at the location.- Parameters:
where- specifies where to insert the element, using one of the following values (case-insensitive): beforebegin, afterbegin, beforeend, afterendinsertedElement- the element to be inserted- Returns:
- an element object
- See Also:
- MSDN
-
insertAdjacentText
public void insertAdjacentText(java.lang.String where, java.lang.String text)Inserts the given text into the element at the specified location.- Parameters:
where- specifies where to insert the text, using one of the following values (case-insensitive): beforebegin, afterbegin, beforeend, afterendtext- the text to insert- See Also:
- MSDN
-
getInsertAdjacentLocation
private java.lang.Object[] getInsertAdjacentLocation(java.lang.String where)
Returns where and how to add the new node. Used byinsertAdjacentHTML(String, String),insertAdjacentElement(String, Object)andinsertAdjacentText(String, String).- Parameters:
where- specifies where to insert the element, using one of the following values (case-insensitive): beforebegin, afterbegin, beforeend, afterend- Returns:
- an array of 1-DomNode:parentNode and 2-Boolean:append
-
insertAdjacentHTML
public void insertAdjacentHTML(java.lang.String position, java.lang.String text)Parses the given text as HTML or XML and inserts the resulting nodes into the tree in the position given by the position argument.- Parameters:
position- specifies where to insert the nodes, using one of the following values (case-insensitive):beforebegin,afterbegin,beforeend,afterendtext- the text to parse- See Also:
- W3C Spec, WhatWG Spec, Mozilla Developer Network, MSDN
-
parseHtmlSnippet
private static void parseHtmlSnippet(DomNode target, java.lang.String source)
Parses the specified HTML source code, appending the resulting content at the specified target location.- Parameters:
target- the node indicating the position at which the parsed content should be placedsource- the HTML code extract to parse
-
innerHTML
public java.lang.String innerHTML()
ThegetInnerHTMLfunction.- Returns:
- the contents of this node as HTML
-
getInnerHTML
public java.lang.String getInnerHTML()
Gets theinnerHTMLattribute.- Returns:
- the contents of this node as HTML
-
setInnerHTML
public void setInnerHTML(java.lang.Object value)
Replaces all child elements of this element with the supplied value.- Parameters:
value- the new value for the contents of this element
-
getInnerHTML
protected java.lang.String getInnerHTML(DomNode domNode)
Helper for getInnerHtml (to be reuses bei HTMLTemplate.- Parameters:
domNode- the node- Returns:
- the contents of this node as HTML
-
getOuterHTML
public java.lang.String getOuterHTML()
Gets the outerHTML of the node.- Returns:
- the contents of this node as HTML
- See Also:
- MSDN documentation
-
setOuterHTML
public void setOuterHTML(java.lang.Object value)
Replaces this element (including all child elements) with the supplied value.- Parameters:
value- the new value for replacing this element
-
printChildren
protected final void printChildren(java.lang.StringBuilder builder, DomNode node, boolean html)Helper for getting code back from nodes.- Parameters:
builder- the builder to write tonode- the node to be serializedhtml- flag
-
printNode
protected void printNode(java.lang.StringBuilder builder, DomNode node, boolean html)
-
isEndTagForbidden
protected boolean isEndTagForbidden()
Returns whether the end tag is forbidden or not.- Returns:
- whether the end tag is forbidden or not
- See Also:
- HTML 4 specs
-
getId
public java.lang.String getId()
Returns the element ID.- Returns:
- the ID of this element
-
setId
public void setId(java.lang.String newId)
Sets the id value for this element.- Parameters:
newId- the newId value for this element
-
removeAttributeNode
public void removeAttributeNode(Attr attribute)
Removes the specified attribute.- Parameters:
attribute- the attribute to remove
-
getScrollTop
public int getScrollTop()
Gets the scrollTop value for this element.- Returns:
- the scrollTop value for this element
- See Also:
- MSDN documentation
-
setScrollTop
public void setScrollTop(int scroll)
Sets the scrollTop value for this element.- Parameters:
scroll- the scrollTop value for this element
-
getScrollLeft
public int getScrollLeft()
Gets the scrollLeft value for this element.- Returns:
- the scrollLeft value for this element
- See Also:
- MSDN documentation
-
setScrollLeft
public void setScrollLeft(int scroll)
Sets the scrollLeft value for this element.- Parameters:
scroll- the scrollLeft value for this element
-
getScrollHeight
public int getScrollHeight()
Gets the scrollHeight for this element.- Returns:
- at the moment the same as client height
- See Also:
- MSDN documentation
-
getScrollWidth
public int getScrollWidth()
Gets the scrollWidth for this element.- Returns:
- a dummy value of 10
- See Also:
- MSDN documentation
-
getStyle
protected CSSStyleDeclaration getStyle()
Returns the style object for this element.- Returns:
- the style object for this element
-
setStyle
protected void setStyle(java.lang.String style)
Sets the styles for this element.- Parameters:
style- the style of the element
-
scroll
public void scroll()
Implement thescroll()JavaScript function but don't actually do anything. The requirement is just to prevent scripts that call that method from failing
-
scrollBy
public void scrollBy()
Implement thescrollBy()JavaScript function but don't actually do anything. The requirement is just to prevent scripts that call that method from failing
-
scrollTo
public void scrollTo()
Implement thescrollTo()JavaScript function but don't actually do anything. The requirement is just to prevent scripts that call that method from failing
-
scrollIntoView
public void scrollIntoView()
Implement thescrollIntoView()JavaScript function but don't actually do anything. The requirement is just to prevent scripts that call that method from failing
-
scrollIntoViewIfNeeded
public void scrollIntoViewIfNeeded()
Implement thescrollIntoViewIfNeeded()JavaScript function but don't actually do anything.
-
getPrefix
public java.lang.Object getPrefix()
Returns the namespace prefix.
-
getLocalName
public java.lang.Object getLocalName()
Returns the local name of this attribute.- Overrides:
getLocalNamein classNode- Returns:
- the local name of this attribute
-
getNamespaceURI
public java.lang.Object 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
public void setOnbeforecopy(java.lang.Object onbeforecopy)
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
public void setOnbeforecut(java.lang.Object onbeforecut)
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
public void setOnbeforepaste(java.lang.Object onbeforepaste)
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
public void setOnsearch(java.lang.Object onsearch)
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
public void setOnwebkitfullscreenchange(java.lang.Object onwebkitfullscreenchange)
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
public void setOnwebkitfullscreenerror(java.lang.Object onwebkitfullscreenerror)
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
public void setOnwheel(java.lang.Object onwheel)
Sets theonwheelevent handler for this element.- Parameters:
onwheel- theonwheelevent handler for this element
-
remove
public void remove()
Removes the DOM node from its parent.- Overrides:
removein classNode- See Also:
- MDN documentation
-
setCapture
public void setCapture(boolean retargetToElement)
Mock for the moment.- Parameters:
retargetToElement- if true, all events are targeted directly to this element; if false, events can also fire at descendants of this element
-
releaseCapture
public void releaseCapture()
Mock for the moment.
-
before
public static void before(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode.- 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.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode.- 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.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Replaces the node with a set of Node or DOMString objects.- 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.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
- the value
-
mozMatchesSelector
public static boolean mozMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
- the value
-
webkitMatchesSelector
public static boolean webkitMatchesSelector(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Returns true if the element would be selected by the specified selector string; otherwise, returns false.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
- the value
-
closest
public static Element closest(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)
-
toggleAttribute
public boolean toggleAttribute(java.lang.String name, java.lang.Object force)ThetoggleAttribute()method of the Element interface toggles a Boolean attribute (removing it if it is present and adding it if it is not present) on the given element. Ifforceistrue, adds boolean attribute withname. Ifforceisfalse, removes attribute withname.- Parameters:
name- the name of the attribute to be toggled. The attribute name is automatically converted to all lower-case when toggleAttribute() is called on an HTML element in an HTML document.force- if true, the toggleAttribute method adds an attribute named name- Returns:
- true if attribute name is eventually present, and false otherwise
- See Also:
- Element.toggleAttribute()
-
append
public static void append(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node objects or string objects after the last child of the Element. String objects are inserted as equivalent Text nodes.- 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.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Inserts a set of Node objects or string objects before the first child of the Element. String objects are inserted as equivalent Text nodes.- 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.Scriptable scope, org.htmlunit.corejs.javascript.Scriptable thisObj, java.lang.Object[] args, org.htmlunit.corejs.javascript.Function function)Replaces the existing children of a Node with a specified new set of children. These can be string or Node objects.- Parameters:
context- the contextscope- the scopethisObj- this objectargs- the argumentsfunction- the function
-
-