java.lang.Object
org.htmlunit.corejs.javascript.SlotMapOwner<org.htmlunit.corejs.javascript.Scriptable>
org.htmlunit.corejs.javascript.ScriptableObject
org.htmlunit.javascript.HtmlUnitScriptable
org.htmlunit.javascript.host.event.EventTarget
org.htmlunit.javascript.host.dom.Node
- 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:
Attr,CharacterData,Document,DocumentFragment,DocumentType,Element
The JavaScript object
Node which is the base class for all DOM
objects. This will typically wrap an instance of DomNode.- Author:
- Mike Bowler, David K. Taylor, Barnaby Court, Christian Sell, George Murnock, Chris Erskine, Bruce Faulkner, Ahmed Ashour, Ronald Brill, Frank Danek
- 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
FieldsModifier and TypeFieldDescriptionstatic final intThe node is an attribute.static final intThe node is a CDATA section.static final intThe node is a comment.static final intThe node is a document fragment.static final intThe node is a document.static final intThe reference node is contained by the other node.static final intThe reference node contains the other node.static final intThe nodes are disconnected.static final intThe reference node follows the other node.static final intThe document position is implementation-specific.static final intThe reference node precedes the other node.static final intThe node is a document type.static final intThe node is an element.static final intThe node is an entity.static final intThe node is an entity reference.static final intThe node is a notation.static final intThe node is a processing instruction.static final intThe node is a text node.Fields inherited from class org.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONSTFields inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
isSealedFields inherited from interface org.htmlunit.corejs.javascript.Scriptable
NOT_FOUND -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidafter(org.htmlunit.corejs.javascript.Context context, 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.protected static voidappend(org.htmlunit.corejs.javascript.Context context, 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.appendChild(Object childObject) Adds a DOM node to the node.protected static voidbefore(org.htmlunit.corejs.javascript.Context context, 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.cloneNode(boolean deep) Clones this node.intCompares the positions of this node and the provided node within the document.booleanReturns whether the specified node is contained within this node.Returns the attributes of this XML element.Returns the Base URI as a string.protected intReturns the current number of child elements.Returns the child nodes of the current element.protected HTMLCollectionReturns the child elements of this node.Gets the JavaScript propertyfirstChildfor the node that contains the current node.protected ElementReturns the first element child.protected NodegetJavaScriptNode(DomNode domNode) Gets the JavaScript node for a given DomNode.Gets the JavaScript propertylastChildfor the node that contains the current node.protected ElementReturns the last element child.Returns the local name of this attribute.Returns the URI that identifies an XML namespace.Gets the JavaScript propertynextSiblingfor the node that contains the current node.Gets the JavaScript propertynodeNamefor the current node.intGets the JavaScript propertynodeTypefor the current node.Gets the JavaScript propertynodeValuefor the current node.Returns the owner document.final NodeReturns this node's parent node.Gets the JavaScript propertyparentElement.Gets the JavaScript propertyparentNodefor the node that contains the current node.Returns the namespace prefix.Gets the JavaScript propertypreviousSiblingfor the node that contains the current node.Returns the root node of this node's tree.Gets the textContent attribute.booleanReturns whether this node has any attributes.booleanReturns whether this node has any child nodes.static NodeinsertBefore(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) Add a DOM node as a child to this node before the referenced node.protected NodeinsertBeforeImpl(Object[] args) Add a DOM node as a child to this node before the referenced node.booleanisEqualNode(Node other) Determines whether this node is structurally equal to the specified node.booleanisSameNode(Object other) Determines whether this node and the specified node are the same object.voidJavaScript constructor.lookupPrefix(String namespace) Returns the namespace prefix for the specified namespace URI.static voidmoveBefore(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.VarScope scope, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Moves a given Node inside the invoking node as a direct child, before a given reference node.voidMerges adjacent TextNode objects to produce a normalized document object model.protected static voidprepend(org.htmlunit.corejs.javascript.Context context, 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 voidremove()Removes the DOM node from its parent.removeChild(Object childObject) Removes a DOM node from this node.replaceChild(Object newChildObject, Object oldChildObject) Replaces a child DOM node with another DOM node.protected static voidreplaceChildren(org.htmlunit.corejs.javascript.Context context, 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.protected static voidreplaceWith(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces this ChildNode in the children list of its parent with a set of Node or DOMString objects.voidsetNodeValue(String newValue) Sets the JavaScript propertynodeValuefor the current node.voidsetTextContent(Object value) Replace all children elements of this element with the supplied value.Methods inherited from class org.htmlunit.javascript.host.event.EventTarget
addEventListener, clearEventListenersContainer, dispatchEvent, executeEventLocally, fireEvent, getEventHandler, getEventListenersContainer, hasEventHandlers, isEventHandlerOnWindow, removeEventListener, setEventHandlerMethods inherited from class org.htmlunit.javascript.HtmlUnitScriptable
clone, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getWindow, getWindow, getWindowOrWorkerGlobalScope, getWithPreemption, has, hasInstance, makeScriptableFor, put, setClassName, setDomNode, setDomNode, setupPromise, setupRejectedPromiseMethods inherited from class org.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, checkNotSealed, checkPropertyChangeForSlot, checkPropertyChangeForSlot, checkPropertyDefinition, checkPropertyDefinition, checkSlotRemoval, defineBuiltinProperty, defineBuiltinProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineBuiltInProperty, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineOwnProperties, defineOwnProperty, defineOwnProperty, defineOwnProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, delete, deleteProperty, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, ensureScriptableObjectButNotSymbol, ensureSymbolScriptable, ensureType, get, get, getAllIds, getAncestor, getArrayPrototype, getClassPrototype, getClassPrototype, getDefaultValue, getExternalArrayData, getExternalArrayLength, getFunctionPrototype, getGeneratorFunctionPrototype, getGetterOrSetter, getGetterOrSetter, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyIds, getPrototype, getSuperProperty, getSuperProperty, getSuperProperty, getThis, getTopLevelScope, getTopScopeValue, getTypedProperty, getTypedProperty, getTypeOf, hasProperty, hasProperty, hasProperty, hasProperty, isAccessorDescriptor, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGenericDescriptor, isGetterOrSetter, isGetterOrSetter, isTrue, preventExtensions, put, put, putConst, putConstProperty, putConstProperty, putOwnProperty, putOwnProperty, putOwnProperty, putProperty, putProperty, putProperty, putProperty, putSuperProperty, putSuperProperty, putSuperProperty, querySlot, redefineProperty, redefineProperty, sameValue, sealObject, setCommonDescriptorProperties, setExternalArrayData, setGetterOrSetter, setParentScope, setPrototype, sizeMethods inherited from class org.htmlunit.corejs.javascript.SlotMapOwner
associateValue, checkNotSealed, copyAssociatedValue, createSlotMap, defineProperty, defineProperty, get, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getAttributes, getIds, has, has, isSealed, readMaps, setAttributes, setAttributes, setAttributes, setAttributes, setAttributes, writeMapsMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.htmlunit.corejs.javascript.Scriptable
get, getIds, has, hasMethods inherited from interface org.htmlunit.corejs.javascript.SymbolScriptable
get, has
-
Field Details
-
ELEMENT_NODE
public static final int ELEMENT_NODEThe node is an element.- See Also:
-
ATTRIBUTE_NODE
public static final int ATTRIBUTE_NODEThe node is an attribute.- See Also:
-
TEXT_NODE
public static final int TEXT_NODEThe node is a text node.- See Also:
-
CDATA_SECTION_NODE
public static final int CDATA_SECTION_NODEThe node is a CDATA section.- See Also:
-
ENTITY_REFERENCE_NODE
public static final int ENTITY_REFERENCE_NODEThe node is an entity reference. -
ENTITY_NODE
public static final int ENTITY_NODEThe node is an entity.- See Also:
-
PROCESSING_INSTRUCTION_NODE
public static final int PROCESSING_INSTRUCTION_NODEThe node is a processing instruction. -
COMMENT_NODE
public static final int COMMENT_NODEThe node is a comment.- See Also:
-
DOCUMENT_NODE
public static final int DOCUMENT_NODEThe node is a document.- See Also:
-
DOCUMENT_TYPE_NODE
public static final int DOCUMENT_TYPE_NODEThe node is a document type.- See Also:
-
DOCUMENT_FRAGMENT_NODE
public static final int DOCUMENT_FRAGMENT_NODEThe node is a document fragment. -
NOTATION_NODE
public static final int NOTATION_NODEThe node is a notation.- See Also:
-
DOCUMENT_POSITION_DISCONNECTED
public static final int DOCUMENT_POSITION_DISCONNECTEDThe nodes are disconnected. -
DOCUMENT_POSITION_PRECEDING
public static final int DOCUMENT_POSITION_PRECEDINGThe reference node precedes the other node. -
DOCUMENT_POSITION_FOLLOWING
public static final int DOCUMENT_POSITION_FOLLOWINGThe reference node follows the other node. -
DOCUMENT_POSITION_CONTAINS
public static final int DOCUMENT_POSITION_CONTAINSThe reference node contains the other node. -
DOCUMENT_POSITION_CONTAINED_BY
public static final int DOCUMENT_POSITION_CONTAINED_BYThe reference node is contained by the other node. -
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC
public static final int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFICThe document position is implementation-specific.
-
-
Constructor Details
-
Node
public Node()
-
-
Method Details
-
jsConstructor
public void jsConstructor()JavaScript constructor.- Overrides:
jsConstructorin classEventTarget
-
getNodeType
public int getNodeType()Gets the JavaScript propertynodeTypefor the current node.- Returns:
- the node type
-
getNodeName
Gets the JavaScript propertynodeNamefor the current node.- Returns:
- the node name
-
getNodeValue
Gets the JavaScript propertynodeValuefor the current node.- Returns:
- the node value
-
setNodeValue
Sets the JavaScript propertynodeValuefor the current node.- Parameters:
newValue- the new node value
-
appendChild
Adds a DOM node to the node.- Parameters:
childObject- the node to add to this node- Returns:
- the newly added child node
-
insertBefore
public static Node insertBefore(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) Add a DOM node as a child to this node before the referenced node. If the referenced node is null, append to the end.- Parameters:
context- the JavaScript contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function- Returns:
- the newly added child node
-
insertBeforeImpl
Add a DOM node as a child to this node before the referenced node. If the referenced node is null, append to the end.- Parameters:
args- the arguments- Returns:
- the newly added child node
-
remove
protected void remove()Removes the DOM node from its parent.- See Also:
-
removeChild
Removes a DOM node from this node.- Parameters:
childObject- the node to remove from this node- Returns:
- the removed child node
-
replaceChild
Replaces a child DOM node with another DOM node.- Parameters:
newChildObject- the node to add as a child of this nodeoldChildObject- the node to remove as a child of this node- Returns:
- the removed child node
-
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 contextscope- the scopethisObj- the scriptableargs- the arguments passed into the methodfunction- the function
-
cloneNode
Clones this node.- Parameters:
deep- iftrue, recursively clones all descendants- Returns:
- the newly cloned node
-
isEqualNode
Determines whether this node is structurally equal to the specified node.- Parameters:
other- the node to compare with- Returns:
trueif the two nodes are structurally equal- See Also:
-
isSameNode
Determines whether this node and the specified node are the same object.- Parameters:
other- the node to test against- Returns:
trueif this node is the same node as the given one
-
hasChildNodes
public boolean hasChildNodes()Returns whether this node has any child nodes.- Returns:
trueif this node has any child nodes
-
lookupPrefix
Returns the namespace prefix for the specified namespace URI.- Parameters:
namespace- the namespace URI- Returns:
- the corresponding namespace prefix, or
nullif none exists; if multiple prefixes are possible, the first one is returned
-
getChildNodes
Returns the child nodes of the current element.- Returns:
- the child nodes of the current element
-
getParent
Returns this node's parent node.- Returns:
- this node's parent node
-
getParentNode
Gets the JavaScript propertyparentNodefor the node that contains the current node.- Returns:
- the parent node
-
getNextSibling
Gets the JavaScript propertynextSiblingfor the node that contains the current node.- Returns:
- the next sibling node or null if the current node has no next sibling.
-
getPreviousSibling
Gets the JavaScript propertypreviousSiblingfor the node that contains the current node.- Returns:
- the previous sibling node or null if the current node has no previous sibling.
-
getFirstChild
Gets the JavaScript propertyfirstChildfor the node that contains the current node.- Returns:
- the first child node or null if the current node has no children.
-
getLastChild
Gets the JavaScript propertylastChildfor the node that contains the current node.- Returns:
- the last child node or null if the current node has no children.
-
getJavaScriptNode
Gets the JavaScript node for a given DomNode.- Parameters:
domNode- the DomNode- Returns:
- the JavaScript node or null if the DomNode was null
-
getOwnerDocument
Returns the owner document.- Returns:
- the document
-
getRootNode
Returns the root node of this node's tree.- Returns:
- the root node
-
compareDocumentPosition
Compares the positions of this node and the provided node within the document.- Parameters:
node- node object that specifies the node to check- Returns:
- how the node is positioned relatively to the reference node.
- See Also:
-
normalize
public void normalize()Merges adjacent TextNode objects to produce a normalized document object model. -
getTextContent
Gets the textContent attribute.- Returns:
- the contents of this node as text
-
setTextContent
Replace all children elements of this element with the supplied value.- Parameters:
value- - the new value for the contents of this node
-
getParentElement
Gets the JavaScript propertyparentElement.- Returns:
- the parent element
- See Also:
-
getAttributes
Returns the attributes of this XML element.- Returns:
- the attributes of this XML element
- See Also:
-
contains
Returns whether the specified node is contained within this node.- Parameters:
element- the node to check- Returns:
trueif the specified node is contained within this node
-
getBaseURI
Returns the Base URI as a string.- Returns:
- the Base URI as a string
-
hasAttributes
public boolean hasAttributes()Returns whether this node has any attributes.- Returns:
trueif this node has one or more attributes
-
getPrefix
Returns the namespace prefix.- Returns:
- the namespace prefix
-
getLocalName
Returns the local name of this attribute.- Returns:
- the local name of this attribute
-
getNamespaceURI
Returns the URI that identifies an XML namespace.- Returns:
- the URI that identifies an XML namespace
-
getChildElementCount
protected int getChildElementCount()Returns the current number of child elements.- Returns:
- the child element count
-
getFirstElementChild
Returns the first element child.- Returns:
- the first element child
-
getLastElementChild
Returns the last element child.- Returns:
- the last element child
-
getChildren
Returns the child elements of this node.- Returns:
- a live collection of this node's child elements
- See Also:
-
after
protected static void after(org.htmlunit.corejs.javascript.Context context, 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 contextthisObj- this objectargs- the argumentsfunction- the function
-
append
protected static void append(org.htmlunit.corejs.javascript.Context context, 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 contextthisObj- this objectargs- the argumentsfunction- the function
-
prepend
protected static void prepend(org.htmlunit.corejs.javascript.Context context, 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 contextthisObj- this objectargs- the argumentsfunction- the function
-
replaceChildren
protected static void replaceChildren(org.htmlunit.corejs.javascript.Context context, 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 contextthisObj- this objectargs- the argumentsfunction- the function
-
before
protected static void before(org.htmlunit.corejs.javascript.Context context, 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 contextthisObj- this objectargs- the argumentsfunction- the function
-
replaceWith
protected static void replaceWith(org.htmlunit.corejs.javascript.Context context, org.htmlunit.corejs.javascript.Scriptable thisObj, Object[] args, org.htmlunit.corejs.javascript.Function function) Replaces this ChildNode in the children list of its parent with a set of Node or DOMString objects.- Parameters:
context- the contextthisObj- this objectargs- the argumentsfunction- the function
-