Module org.htmlunit

Class Element

java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
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

public class Element extends Node
A JavaScript 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.corejs.javascript.ScriptableObject

    CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST

    Fields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner

    isSealed

    Fields inherited from interface org.htmlunit.corejs.javascript.Scriptable

    NOT_FOUND
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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 of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode.
    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 of Node objects or string objects after the last child of the Element.
    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 of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode.
    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 the element and its parents (heading toward the document root) until it finds a node that matches the specified CSS selector.
    protected NamedNodeMap
    Creates the JS object for the property attributes.
    protected void
    createEventHandler(String eventName, String attrValue)
    Create the event handler function from the attribute value.
    getAttribute(String attributeName)
     
    org.htmlunit.corejs.javascript.Scriptable
     
    Retrieves an attribute node by name.
    getAttributeNodeNS(String namespaceURI, String localName)
    Returns the specified attribute.
    getAttributeNS(String namespaceURI, String localName)
    Gets the specified attribute.
    Returns the attributes of this XML element.
    Retrieves an object that specifies the bounds of a collection of TextRectangle objects.
    int
    Returns the current number of child elements.
    Gets the children of the current node.
    Gets the token list of class attribute.
    Returns the class defined for this element.
    int
    Returns the clientHeight attribute.
    int
    Returns the clientLeft attribute.
    Retrieves a collection of rectangles that describes the layout of the contents of an object or range within the client.
    int
    Returns clientTop attribute.
    int
    Returns the clientWidth attribute.
    Returns the DOM node that corresponds to this JavaScript object or throw an exception if one cannot be found.
    Returns all the descendant elements with the specified class.
    Returns all the descendant elements with the specified tag name.
    getElementsByTagNameNS(Object namespaceURI, String localName)
    Returns a list of elements with the given tag name belonging to the given namespace.
    Returns the first element child.
    The getHTML function.
    Returns the element ID.
    Gets the innerHTML attribute.
    protected String
    Helper for getInnerHtml (to be reuses bei HTMLTemplate.
    Returns the last element child.
    Returns the local name of this attribute.
    Returns the URI that identifies an XML namespace.
    Returns the next element sibling.
    org.htmlunit.corejs.javascript.Function
    Returns the onbeforecopy event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onbeforecut event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onbeforepaste event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onsearch event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onwebkitfullscreenchange event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onwebkitfullscreenerror event handler for this element.
    org.htmlunit.corejs.javascript.Function
    Returns the onwheel event handler for this element.
    Gets the outerHTML of the node.
    Gets the first ancestor instance of Element.
    Returns the namespace prefix.
    Returns the previous element sibling.
    int
    Gets the scrollHeight for this element.
    int
    Gets the scrollLeft value for this element.
    int
    Gets the scrollTop value for this element.
    int
    Gets the scrollWidth for this element.
    Returns the style object for this element.
    Returns the tag name of this element.
    boolean
    Returns true when an attribute with a given name is specified on this element or has a default value.
    boolean
    hasAttributeNS(String namespaceURI, String localName)
    Test for attribute.
    boolean
    Returns true when the current element has any attributes or not.
    insertAdjacentElement(String where, Object insertedElement)
    Inserts the given element into the element at the location.
    void
    insertAdjacentHTML(String position, 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.
    void
    Inserts the given text into the element at the specified location.
    protected final boolean
    Returns whether the display is none or not.
    protected boolean
    Returns whether the end tag is forbidden or not.
    void
    JavaScript constructor.
    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)
    Returns true if the element would be selected by the specified selector string; otherwise, returns false.
    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 the invoking node as a direct child, before a given reference node.
    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)
    Returns true if the element would be selected by the specified selector string; otherwise, returns false.
    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 of Node objects or string objects before the first child of the Element.
    protected final void
    printChildren(StringBuilder builder, DomNode node, boolean html)
    Helper for getting code back from nodes.
    protected void
    printNode(StringBuilder builder, DomNode node, boolean html)
     
    querySelector(String selectors)
    Returns the first element within the document that matches the specified group of selectors.
    Retrieves all element nodes from descendants of the starting element node that match any selector within the supplied selector strings.
    void
    Mock for the moment.
    void
    Removes the DOM node from its parent.
    void
    Removes the specified attribute.
    void
    Removes the specified attribute.
    void
    removeAttributeNS(String namespaceURI, String localName)
    Removes the specified attribute.
    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 a Node with a specified new set of children.
    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 the node with a set of Node or DOMString objects.
    void
    scroll(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y)
    Scrolls to a particular set of coordinates inside a given element.
    void
    scrollBy(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y)
    Scrolls the element by the given amount.
    void
    Implement the scrollIntoView() JavaScript function but don't actually do anything.
    void
    Implement the scrollIntoViewIfNeeded() JavaScript function but don't actually do anything.
    void
    scrollTo(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y)
    Scrolls to a particular set of coordinates inside a given element.
    void
    setAttribute(String name, String value)
    Sets an attribute.
    Sets the attribute node for the specified attribute.
    void
    setAttributeNS(String namespaceURI, String qualifiedName, String value)
    Sets the specified attribute.
    void
    setCapture(boolean retargetToElement)
    Mock for the moment.
    void
    Sets the class attribute for this element.
    void
    Sets the DOM node that corresponds to this JavaScript object.
    void
    setId(String newId)
    Sets the id value for this element.
    void
    Replaces all child elements of this element with the supplied value.
    void
    setOnbeforecopy(Object onbeforecopy)
    Sets the onbeforecopy event handler for this element.
    void
    setOnbeforecut(Object onbeforecut)
    Sets the onbeforecut event handler for this element.
    void
    setOnbeforepaste(Object onbeforepaste)
    Sets the onbeforepaste event handler for this element.
    void
    setOnsearch(Object onsearch)
    Sets the onsearch event handler for this element.
    void
    setOnwebkitfullscreenchange(Object onwebkitfullscreenchange)
    Sets the onwebkitfullscreenchange event handler for this element.
    void
    setOnwebkitfullscreenerror(Object onwebkitfullscreenerror)
    Sets the onwebkitfullscreenerror event handler for this element.
    void
    setOnwheel(Object onwheel)
    Sets the onwheel event handler for this element.
    void
    Replaces this element (including all child elements) with the supplied value.
    void
    setScrollLeft(int scroll)
    Sets the scrollLeft value for this element.
    void
    setScrollTop(int scroll)
    Sets the scrollTop value for this element.
    protected void
    Sets the styles for this element.
    boolean
    The toggleAttribute() 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 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)
    Returns true if the element would be selected by the specified selector string; otherwise, returns false.

    Methods 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, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, 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, size

    Methods 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, writeMaps

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.htmlunit.corejs.javascript.Scriptable

    get, getIds, has, has

    Methods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable

    get, has
  • Constructor Details

    • Element

      public Element()
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
      Overrides:
      jsConstructor in class Node
    • setDomNode

      public void setDomNode(DomNode domNode)
      Sets the DOM node that corresponds to this JavaScript object.
      Overrides:
      setDomNode in class HtmlUnitScriptable
      Parameters:
      domNode - the DOM node
    • createEventHandler

      protected void createEventHandler(String eventName, String attrValue)
      Create the event handler function from the attribute value.
      Parameters:
      eventName - the event name (ex: "onclick")
      attrValue - the attribute value
    • getTagName

      public 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:
      getAttributes in class Node
      Returns:
      the attributes of this XML element
      See Also:
    • createAttributesObject

      protected NamedNodeMap createAttributesObject()
      Creates the JS object for the property attributes. This object will be cached.
      Returns:
      the JS object
    • getAttribute

      public String getAttribute(String attributeName)
      Parameters:
      attributeName - attribute name
      Returns:
      the value of the specified attribute, null if the attribute is not defined
    • setAttribute

      public void setAttribute(String name, String value)
      Sets an attribute.
      Parameters:
      name - Name of the attribute to set
      value - Value to set the attribute to
    • getElementsByTagName

      public HTMLCollection getElementsByTagName(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(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 null if there is no such attribute
    • getElementsByTagNameNS

      public HTMLCollection getElementsByTagNameNS(Object namespaceURI, 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 for
      localName - 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(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:
      hasAttributes in class Node
      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:
      getDomNodeOrDie in class HtmlUnitScriptable
      Returns:
      the DOM node
    • removeAttribute

      public void removeAttribute(String name)
      Removes the specified attribute.
      Parameters:
      name - the name of the attribute to remove
    • getBoundingClientRect

      public DOMRect 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:
    • getChildElementCount

      public int getChildElementCount()
      Returns the current number of child elements.
      Overrides:
      getChildElementCount in class Node
      Returns:
      the child element count
    • getFirstElementChild

      public Element getFirstElementChild()
      Returns the first element child.
      Overrides:
      getFirstElementChild in class Node
      Returns:
      the first element child
    • getLastElementChild

      public Element getLastElementChild()
      Returns the last element child.
      Overrides:
      getLastElementChild in class Node
      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 of Element. It is mostly identical to Node.getParent() except that it skips non Element nodes.
      Overrides:
      getParentElement in class Node
      Returns:
      the parent element
      See Also:
    • getChildren

      public HTMLCollection getChildren()
      Gets the children of the current node.
      Overrides:
      getChildren in class Node
      Returns:
      the child at the given position
      See Also:
    • getClassList

      public DOMTokenList getClassList()
      Gets the token list of class attribute.
      Returns:
      the token list of class attribute
    • getAttributeNS

      public String getAttributeNS(String namespaceURI, String localName)
      Gets the specified attribute.
      Parameters:
      namespaceURI - the namespace URI
      localName - the local name of the attribute to look for
      Returns:
      the value of the specified attribute, null if the attribute is not defined
    • hasAttributeNS

      public boolean hasAttributeNS(String namespaceURI, String localName)
      Test for attribute. See also the DOM reference
      Parameters:
      namespaceURI - the namespace URI
      localName - the local name of the attribute to look for
      Returns:
      true if the node has this attribute
    • setAttributeNS

      public void setAttributeNS(String namespaceURI, String qualifiedName, String value)
      Sets the specified attribute.
      Parameters:
      namespaceURI - the namespace URI
      qualifiedName - the qualified name of the attribute to look for
      value - the new attribute value
    • removeAttributeNS

      public void removeAttributeNS(String namespaceURI, String localName)
      Removes the specified attribute.
      Parameters:
      namespaceURI - the namespace URI of the attribute to remove
      localName - 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(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(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 String getClassName_js()
      Returns the class defined for this element.
      Returns:
      the class name
    • setClassName_js

      public void setClassName_js(String className)
      Sets the class attribute for this element.
      Parameters:
      className - the new class name
    • getClientHeight

      public int getClientHeight()
      Returns the clientHeight attribute.
      Returns:
      the clientHeight attribute
    • getClientWidth

      public int getClientWidth()
      Returns the clientWidth attribute.
      Returns:
      the clientWidth attribute
    • getClientLeft

      public int getClientLeft()
      Returns the clientLeft attribute.
      Returns:
      the clientLeft attribute
    • getClientTop

      public int getClientTop()
      Returns clientTop attribute.
      Returns:
      the clientTop attribute
    • getAttributeNodeNS

      public HtmlUnitScriptable getAttributeNodeNS(String namespaceURI, String localName)
      Returns the specified attribute.
      Parameters:
      namespaceURI - the namespace URI
      localName - the local name of the attribute to look for
      Returns:
      the specified attribute, null if the attribute is not defined
    • getElementsByClassName

      public HTMLCollection getElementsByClassName(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 DOMRectList 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
    • getAttributeNames

      public org.htmlunit.corejs.javascript.Scriptable getAttributeNames()
      Returns:
      the attribute names of the element as an Array of strings. If the element has no attributes it returns an empty array.
    • isDisplayNone

      protected final boolean isDisplayNone()
      Returns whether the display is none or not.
      Returns:
      whether the display is none or not
    • insertAdjacentElement

      public Node insertAdjacentElement(String where, 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, afterend
      insertedElement - the element to be inserted
      Returns:
      an element object
      See Also:
    • insertAdjacentText

      public void insertAdjacentText(String where, 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, afterend
      text - the text to insert
      See Also:
    • insertAdjacentHTML

      public void insertAdjacentHTML(String position, 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, afterend
      text - the text to parse
      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 the invoking node as a direct child, before a given reference node.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
    • getHTML

      public String getHTML()
      The getHTML function.
      Returns:
      the contents of this node as HTML
    • getInnerHTML

      public String getInnerHTML()
      Gets the innerHTML attribute.
      Returns:
      the contents of this node as HTML
    • setInnerHTML

      public void setInnerHTML(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 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 String getOuterHTML()
      Gets the outerHTML of the node.
      Returns:
      the contents of this node as HTML
      See Also:
    • setOuterHTML

      public void setOuterHTML(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(StringBuilder builder, DomNode node, boolean html)
      Helper for getting code back from nodes.
      Parameters:
      builder - the builder to write to
      node - the node to be serialized
      html - flag
    • printNode

      protected void printNode(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:
    • getId

      public String getId()
      Returns the element ID.
      Returns:
      the ID of this element
    • setId

      public void setId(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:
    • 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:
    • 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:
    • getScrollWidth

      public int getScrollWidth()
      Gets the scrollWidth for this element.
      Returns:
      a dummy value of 10
      See Also:
    • getStyle

      protected CSSStyleDeclaration getStyle()
      Returns the style object for this element.
      Returns:
      the style object for this element
    • setStyle

      protected void setStyle(String style)
      Sets the styles for this element.
      Parameters:
      style - the style of the element
    • scroll

      public void scroll(org.htmlunit.corejs.javascript.Scriptable x, org.htmlunit.corejs.javascript.Scriptable y)
      Scrolls to a particular set of coordinates inside a given element.
      Parameters:
      x - the horizontal pixel value that you want to scroll to
      y - the vertical pixel value that you want 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 that you want to scroll by
      y - the vertical pixel value that you want 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 a given element.
      Parameters:
      x - the horizontal pixel value that you want to scroll to
      y - the vertical pixel value that you want to scroll to
    • scrollIntoView

      public void scrollIntoView()
      Implement the scrollIntoView() 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 the scrollIntoViewIfNeeded() JavaScript function but don't actually do anything.
    • getPrefix

      public String getPrefix()
      Returns the namespace prefix.
      Overrides:
      getPrefix in class Node
      Returns:
      the namespace prefix
    • getLocalName

      public String getLocalName()
      Returns the local name of this attribute.
      Overrides:
      getLocalName in class Node
      Returns:
      the local name of this attribute
    • getNamespaceURI

      public String getNamespaceURI()
      Returns the URI that identifies an XML namespace.
      Overrides:
      getNamespaceURI in class Node
      Returns:
      the URI that identifies an XML namespace
    • getOnbeforecopy

      public org.htmlunit.corejs.javascript.Function getOnbeforecopy()
      Returns the onbeforecopy event handler for this element.
      Returns:
      the onbeforecopy event handler for this element
    • setOnbeforecopy

      public void setOnbeforecopy(Object onbeforecopy)
      Sets the onbeforecopy event handler for this element.
      Parameters:
      onbeforecopy - the onbeforecopy event handler for this element
    • getOnbeforecut

      public org.htmlunit.corejs.javascript.Function getOnbeforecut()
      Returns the onbeforecut event handler for this element.
      Returns:
      the onbeforecut event handler for this element
    • setOnbeforecut

      public void setOnbeforecut(Object onbeforecut)
      Sets the onbeforecut event handler for this element.
      Parameters:
      onbeforecut - the onbeforecut event handler for this element
    • getOnbeforepaste

      public org.htmlunit.corejs.javascript.Function getOnbeforepaste()
      Returns the onbeforepaste event handler for this element.
      Returns:
      the onbeforepaste event handler for this element
    • setOnbeforepaste

      public void setOnbeforepaste(Object onbeforepaste)
      Sets the onbeforepaste event handler for this element.
      Parameters:
      onbeforepaste - the onbeforepaste event handler for this element
    • getOnsearch

      public org.htmlunit.corejs.javascript.Function getOnsearch()
      Returns the onsearch event handler for this element.
      Returns:
      the onsearch event handler for this element
    • setOnsearch

      public void setOnsearch(Object onsearch)
      Sets the onsearch event handler for this element.
      Parameters:
      onsearch - the onsearch event handler for this element
    • getOnwebkitfullscreenchange

      public org.htmlunit.corejs.javascript.Function getOnwebkitfullscreenchange()
      Returns the onwebkitfullscreenchange event handler for this element.
      Returns:
      the onwebkitfullscreenchange event handler for this element
    • setOnwebkitfullscreenchange

      public void setOnwebkitfullscreenchange(Object onwebkitfullscreenchange)
      Sets the onwebkitfullscreenchange event handler for this element.
      Parameters:
      onwebkitfullscreenchange - the onwebkitfullscreenchange event handler for this element
    • getOnwebkitfullscreenerror

      public org.htmlunit.corejs.javascript.Function getOnwebkitfullscreenerror()
      Returns the onwebkitfullscreenerror event handler for this element.
      Returns:
      the onwebkitfullscreenerror event handler for this element
    • setOnwebkitfullscreenerror

      public void setOnwebkitfullscreenerror(Object onwebkitfullscreenerror)
      Sets the onwebkitfullscreenerror event handler for this element.
      Parameters:
      onwebkitfullscreenerror - the onwebkitfullscreenerror event handler for this element
    • getOnwheel

      public org.htmlunit.corejs.javascript.Function getOnwheel()
      Returns the onwheel event handler for this element.
      Returns:
      the onwheel event handler for this element
    • setOnwheel

      public void setOnwheel(Object onwheel)
      Sets the onwheel event handler for this element.
      Parameters:
      onwheel - the onwheel event handler for this element
    • remove

      public void remove()
      Removes the DOM node from its parent.
      Overrides:
      remove in class Node
      See Also:
    • 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.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, 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 context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - 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 of Node or DOMString objects in the children list of this ChildNode's parent, just after this ChildNode.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - 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 the node with a set of Node or DOMString objects.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - 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)
      Returns true if the element would be selected by the specified selector string; otherwise, returns false.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
      Returns:
      the value
    • 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)
      Returns true if the element would be selected by the specified selector string; otherwise, returns false.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
      Returns:
      the value
    • 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)
      Returns true if the element would be selected by the specified selector string; otherwise, returns false.
      Parameters:
      context - the JavaScript context
      scope - the scope
      thisObj - the scriptable
      args - the arguments passed into the method
      function - the function
      Returns:
      the value
    • 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 the element and its parents (heading toward the document root) until it finds a node that matches the specified CSS selector.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - the function
      Returns:
      the found element or null
    • toggleAttribute

      public boolean toggleAttribute(String name, Object force)
      The toggleAttribute() 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. If force is true, adds boolean attribute with name. If force is false, removes attribute with name.
      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:
    • 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 of Node objects or string objects after the last child of the Element. String objects are inserted as equivalent Text nodes.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - 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 of Node objects or string objects before the first child of the Element. String objects are inserted as equivalent Text nodes.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - 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 a Node with a specified new set of children. These can be string or Node objects.
      Parameters:
      context - the context
      scope - the scope
      thisObj - this object
      args - the arguments
      function - the function