Module org.htmlunit

Class DocumentFragment

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:
ShadowRoot

public class DocumentFragment extends Node
A JavaScript object for DocumentFragment.
Author:
Ahmed Ashour, Frank Danek, Ronald Brill
See Also:
  • Constructor Details

    • DocumentFragment

      public DocumentFragment()
  • Method Details

    • jsConstructor

      public void jsConstructor()
      JavaScript constructor.
      Overrides:
      jsConstructor in class Node
    • 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 document fragment. 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 document fragment. 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 DocumentFragment 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
    • 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
    • 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
    • getDefaultValue

      public Object getDefaultValue(Class<?> hint)
      Returns the JavaScript default value of this object. This is the JavaScript equivalent of a toString() in Java.
      Specified by:
      getDefaultValue in interface org.htmlunit.corejs.javascript.Scriptable
      Overrides:
      getDefaultValue in class HtmlUnitScriptable
      Parameters:
      hint - a hint as to the format of the default value (ignored in this case)
      Returns:
      the default value
    • 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
    • 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:
    • getElementById

      public HtmlUnitScriptable getElementById(Object id)
      Returns the element with the specified ID, or null if that element could not be found.
      Parameters:
      id - the ID to search for
      Returns:
      the element, or null if it could not be found
    • getRootNode

      public Node getRootNode()
      Returns the owner document.
      Overrides:
      getRootNode in class Node
      Returns:
      the document