Appearance
Node ​
class Node extends EventTargetAnnotations: @Native.new("Node")
Inheritance
Object → EventTarget → Node
Implementers
Properties ​
baseUri no setter ​
String? get baseUriImplementation
dart
@JSName('baseURI')
String? get baseUri native;childNodes no setter ​
A list of this node's children.
Other resources ​
- Node.childNodes from MDN.
Implementation
dart
@Returns('NodeList')
@Creates('NodeList')
List<Node> get childNodes native;firstChild no setter ​
Node? get firstChildThe first child of this node.
Other resources ​
- Node.firstChild from MDN.
Implementation
dart
Node? get firstChild native;hashCode no setter inherited ​
int get hashCodeInherited from Interceptor.
Implementation
dart
int get hashCode => Primitives.objectHashCode(this);isConnected no setter ​
bool? get isConnectedImplementation
dart
bool? get isConnected native;lastChild no setter ​
Node? get lastChildThe last child of this node.
Other resources ​
- Node.lastChild from MDN.
Implementation
dart
Node? get lastChild native;nextNode no setter ​
Node? get nextNodeThe next sibling node.
Other resources ​
- Node.nextSibling from MDN.
Implementation
dart
@JSName('nextSibling')
/**
* The next sibling node.
*
* ## Other resources
*
* * [Node.nextSibling](https://developer.mozilla.org/en-US/docs/Web/API/Node.nextSibling)
* from MDN.
*/
Node? get nextNode native;nodeName no setter ​
String? get nodeNameThe name of this node.
This varies by this node's nodeType.
Other resources ​
- Node.nodeName from MDN. This page contains a table of nodeName values for each nodeType.
Implementation
dart
String? get nodeName native;nodes read / write ​
A modifiable list of this node's children.
Implementation
dart
List<Node> get nodes {
return new _ChildNodeListLazy(this);
}
set nodes(Iterable<Node> value) {
// Copy list first since we don't want liveness during iteration.
// TODO(jacobr): there is a better way to do this.
var copy = value.toList();
text = '';
for (Node node in copy) {
append(node);
}
}nodeType no setter ​
int get nodeTypeThe type of node.
This value is one of:
- ATTRIBUTE_NODE if this node is an attribute.
- CDATA_SECTION_NODE if this node is a CDataSection.
- COMMENT_NODE if this node is a Comment.
- DOCUMENT_FRAGMENT_NODE if this node is a DocumentFragment.
- DOCUMENT_NODE if this node is a Document.
- DOCUMENT_TYPE_NODE if this node is a
_DocumentTypenode. - ELEMENT_NODE if this node is an Element.
- ENTITY_NODE if this node is an entity.
- ENTITY_REFERENCE_NODE if this node is an entity reference.
- NOTATION_NODE if this node is a notation.
- PROCESSING_INSTRUCTION_NODE if this node is a ProcessingInstruction.
- TEXT_NODE if this node is a Text node.
Other resources ​
- Node.nodeType from MDN.
Implementation
dart
int get nodeType native;nodeValue no setter ​
String? get nodeValueThe value of this node.
This varies by this type's nodeType.
Other resources ​
- Node.nodeValue from MDN. This page contains a table of nodeValue values for each nodeType.
Implementation
dart
String? get nodeValue native;on no setter inherited ​
Events get onThis is an ease-of-use accessor for event streams which should only be used when an explicit accessor is not available.
Inherited from EventTarget.
Implementation
dart
Events get on => new Events(this);ownerDocument no setter ​
Document? get ownerDocumentThe document this node belongs to.
Returns null if this node does not belong to any document.
Other resources ​
- Node.ownerDocument from MDN.
Implementation
dart
Document? get ownerDocument native;parent no setter ​
Element? get parentThe parent element of this node.
Returns null if this node either does not have a parent or its parent is not an element.
Other resources ​
- Node.parentElement from W3C.
Implementation
dart
@JSName('parentElement')
/**
* The parent element of this node.
*
* Returns null if this node either does not have a parent or its parent is
* not an element.
*
* ## Other resources
*
* * [Node.parentElement](https://developer.mozilla.org/en-US/docs/Web/API/Node.parentElement)
* from W3C.
*/
Element? get parent native;parentNode no setter ​
Node? get parentNodeThe parent node of this node.
Other resources ​
- Node.parentNode from MDN.
Implementation
dart
Node? get parentNode native;previousNode no setter ​
Node? get previousNodeThe previous sibling node.
Other resources ​
- Node.previousSibling from MDN.
Implementation
dart
@JSName('previousSibling')
/**
* The previous sibling node.
*
* ## Other resources
*
* * [Node.previousSibling](https://developer.mozilla.org/en-US/docs/Web/API/Node.previousSibling)
* from MDN.
*/
Node? get previousNode native;runtimeType no setter inherited ​
Type get runtimeTypeInherited from Interceptor.
Implementation
dart
Type get runtimeType =>
getRuntimeTypeOfInterceptorNotArray(getInterceptor(this), this);text read / write ​
String? get textAll text within this node and its descendants.
Other resources ​
- Node.textContent from MDN.
Implementation
dart
@JSName('textContent')
/**
* All text within this node and its descendants.
*
* ## Other resources
*
* * [Node.textContent](https://developer.mozilla.org/en-US/docs/Web/API/Node.textContent)
* from MDN.
*/
String? get text native;
@JSName('textContent')
set text(String? value) native;Methods ​
addEventListener() inherited ​
void addEventListener(
String type,
(dynamic Function(Event event))? listener, [
bool? useCapture,
])Inherited from EventTarget.
Implementation
dart
void addEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_addEventListener(type, listener, useCapture);
}
}append() ​
Adds a node to the end of the child nodes list of this node.
If the node already exists in this document, it will be removed from its current parent node, then added to this node.
This method is more efficient than nodes.add, and is the preferred way of appending a child node.
Implementation
dart
@JSName('appendChild')
/**
* Adds a node to the end of the child [nodes] list of this node.
*
* If the node already exists in this document, it will be removed from its
* current parent node, then added to this node.
*
* This method is more efficient than `nodes.add`, and is the preferred
* way of appending a child node.
*/
Node append(Node node) native;clone() ​
Returns a copy of this node.
If deep is true, then all of this node's children and descendants are copied as well. If deep is false, then only this node is copied.
Other resources ​
- Node.cloneNode from MDN.
Implementation
dart
@JSName('cloneNode')
/**
* Returns a copy of this node.
*
* If [deep] is `true`, then all of this node's children and descendants are
* copied as well. If [deep] is `false`, then only this node is copied.
*
* ## Other resources
*
* * [Node.cloneNode](https://developer.mozilla.org/en-US/docs/Web/API/Node.cloneNode)
* from MDN.
*/
Node clone(bool? deep) native;contains() ​
Returns true if this node contains the specified node.
Other resources ​
- Node.contains from MDN.
Implementation
dart
bool contains(Node? other) native;dispatchEvent() inherited ​
Inherited from EventTarget.
Implementation
dart
bool dispatchEvent(Event event) native;getRootNode() ​
Implementation
dart
Node getRootNode([Map? options]) {
if (options != null) {
var options_1 = convertDartToNative_Dictionary(options);
return _getRootNode_1(options_1);
}
return _getRootNode_2();
}hasChildNodes() ​
bool hasChildNodes()Returns true if this node has any children.
Other resources ​
- Node.hasChildNodes from MDN.
Implementation
dart
bool hasChildNodes() native;insertAllBefore() ​
Inserts all of the nodes into this node directly before child.
See also:
Implementation
dart
void insertAllBefore(Iterable<Node> newNodes, Node child) {
if (newNodes is _ChildNodeListLazy) {
_ChildNodeListLazy otherList = newNodes;
if (identical(otherList._this, this)) {
throw new ArgumentError(newNodes);
}
// Optimized route for copying between nodes.
for (var i = 0, len = otherList.length; i < len; ++i) {
this.insertBefore(otherList._this.firstChild!, child);
}
} else {
for (var node in newNodes) {
this.insertBefore(node, child);
}
}
}insertBefore() ​
Inserts the given node into this node directly before child. If child is null, then the given node is inserted at the end of this node's child nodes.
Other resources ​
- Node.insertBefore from MDN.
Implementation
dart
Node insertBefore(Node node, Node? child) native;noSuchMethod() inherited ​
dynamic noSuchMethod(Invocation invocation)Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dart
dynamic object = 1;
object.add(42); // Statically allowed, run-time errorThis invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
dart
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Interceptor.
Implementation
dart
dynamic noSuchMethod(Invocation invocation) {
throw NoSuchMethodError.withInvocation(this, invocation);
}remove() ​
void remove()Removes this node from the DOM.
Implementation
dart
void remove() {
// TODO(jacobr): should we throw an exception if parent is already null?
// TODO(vsm): Use the native remove when available.
if (this.parentNode != null) {
final Node parent = this.parentNode!;
parent._removeChild(this);
}
}removeEventListener() inherited ​
void removeEventListener(
String type,
(dynamic Function(Event event))? listener, [
bool? useCapture,
])Inherited from EventTarget.
Implementation
dart
void removeEventListener(
String type,
EventListener? listener, [
bool? useCapture,
]) {
// TODO(leafp): This check is avoid a bug in our dispatch code when
// listener is null. The browser treats this call as a no-op in this
// case, so it's fine to short-circuit it, but we should not have to.
if (listener != null) {
_removeEventListener(type, listener, useCapture);
}
}replaceWith() ​
Replaces this node with another node.
Implementation
dart
Node replaceWith(Node otherNode) {
try {
final Node parent = this.parentNode!;
parent._replaceChild(otherNode, this);
} catch (e) {}
return this;
}toString() ​
String toString()Print out a String representation of this Node.
Implementation
dart
String toString() {
String? value = nodeValue; // Fetch DOM Node property once.
return value == null ? super.toString() : value;
}Operators ​
operator ==() inherited ​
The equality operator.
The default behavior for all Objects is to return true if and only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false.Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from Interceptor.
Implementation
dart
bool operator ==(Object other) => identical(this, other);Constants ​
ATTRIBUTE_NODE ​
const int ATTRIBUTE_NODEImplementation
dart
static const int ATTRIBUTE_NODE = 2;CDATA_SECTION_NODE ​
const int CDATA_SECTION_NODEImplementation
dart
static const int CDATA_SECTION_NODE = 4;COMMENT_NODE ​
const int COMMENT_NODEImplementation
dart
static const int COMMENT_NODE = 8;DOCUMENT_FRAGMENT_NODE ​
const int DOCUMENT_FRAGMENT_NODEImplementation
dart
static const int DOCUMENT_FRAGMENT_NODE = 11;DOCUMENT_NODE ​
const int DOCUMENT_NODEImplementation
dart
static const int DOCUMENT_NODE = 9;DOCUMENT_TYPE_NODE ​
const int DOCUMENT_TYPE_NODEImplementation
dart
static const int DOCUMENT_TYPE_NODE = 10;ELEMENT_NODE ​
const int ELEMENT_NODEImplementation
dart
static const int ELEMENT_NODE = 1;ENTITY_NODE ​
const int ENTITY_NODEImplementation
dart
static const int ENTITY_NODE = 6;ENTITY_REFERENCE_NODE ​
const int ENTITY_REFERENCE_NODEImplementation
dart
static const int ENTITY_REFERENCE_NODE = 5;NOTATION_NODE ​
const int NOTATION_NODEImplementation
dart
static const int NOTATION_NODE = 12;PROCESSING_INSTRUCTION_NODE ​
const int PROCESSING_INSTRUCTION_NODEImplementation
dart
static const int PROCESSING_INSTRUCTION_NODE = 7;TEXT_NODE ​
const int TEXT_NODEImplementation
dart
static const int TEXT_NODE = 3;