Skip to main content

VirtualDOMNode


/**
* Represents an abstract Node in a Tree
*/
declare abstract class VirtualNode {
protected constructor(options: IVirtualNodeOptions);

/**
* Returns true if this node is a root.
*/
get isRoot(): boolean;
/**
* Returns true if this node is a leaf.
*/
get isLeaf(): boolean;
/**
* Returns an Observable sending the parent of this node.
* This is useful to detect changes in the parent node.
*/
get parentNode$(): IObservable<IVirtualNodeOrNull>;
/**
* Returns the parent node of this node
*/
get parentNode(): IVirtualNodeOrNull;
/**
* Returns the node before this node, or null if none.
*/
get previousNode(): IVirtualNodeOrNull;
/**
* Returns the node after this node, or null if none.
*/
get nextNode(): IVirtualNodeOrNull;
/**
* Returns the first child node of this node, or null if none.
*/
get firstChild(): IVirtualNodeOrNull;
/**
* Returns the last child node of this node, or null if none.
*/
get lastChild(): IVirtualNodeOrNull;
/**
* Returns true if this node is connected to a root node.
*/
get isConnected(): boolean;
/**
* Returns an Observable sending "true" if this node is connected to a root node, or "false".
* This is useful to detect changes in the "connected state" of this node.
*/
get isConnected$(): IObservable<boolean>;
/**
* Returns an Observable sending the values of the provided Observable "observable", only when this node is connected to a root node.
*/
onConnected$<GValue>(observable: IObservable<GValue>): IObservable<GValue>;
/**
* Returns true if this node contains "childNode".
*/
contains(childNode: VirtualNode): boolean;
/**
* Attaches this node to "parentNode" before "referenceNode".
* Performs some internal verifications to ensure that this operation is possible.
* Returns true if attaching this node was necessary (the node had to move).
*/
attach(parentNode: VirtualNode, referenceNode?: IVirtualNodeOrNull): boolean;
/**
* Returns true if this node may be attached to "childNode".
* It is usually used to prevent invalid Tree to exist (we may think about a <button> containing an <input>)
*/
abstract canAttachChildNode(childNode: VirtualNode): boolean;
/**
* Detaches this node from its parent node.
* Returns true if this operation was necessary (the node had a parent node)
*/
detach(): boolean;
/**
* Returns an Iterator on the list of direct child nodes of this node.
*/
getChildren(): Generator<VirtualNode>;
/**
* Returns an Iterator on the list of direct child nodes of this node, in reverse order (starting from the last one).
* @see getChildren
*/
getChildrenReversed(): Generator<VirtualNode>;
/**
* Returns an Iterator on the list of all child nodes of this node.
*/
getChildrenRecursive(): Generator<VirtualNode>;
/**
* Detaches all the child nodes of this node.
*/
detachChildren(): void;
}