API Docs for: 0.0.1
Show:

vnode Class

Module: vnode
Parent Module: vdom

Delivers the vnode prototype object, which is a virtualisation of an Element inside the Dom. These Elements work smoothless with the vdom (see ...).

vnodes are much quicker to access and walk through than native dom-nodes. However, this is a module you don't need by itself: Element-types use these features under the hood.

Copyright (c) 2014 ITSA - https://github.com/itsa
New BSD License - http://choosealicense.com/licenses/bsd-3-clause/

Methods

_appendChild

(
  • VNode
)
Node private

Defined in src/vdom/partials/vnode.js:1236

Available since 0.0.1

Adds a vnode to the end of the list of vChildNodes.

Syncs with the DOM.

Parameters:

  • VNode Vnode

    vnode to append

Returns:

Node:

the Node that was appended

_cleanData

() private chainable

Defined in src/vdom/partials/vnode.js:1296

Available since 0.0.1

Cleans up (empties) vnode's _data

_cleanupStyle

() private chainable

Defined in src/vdom/partials/vnode.js:1315

Available since 0.0.1

Cleans up (removes) duplicated style definitions.

_deleteFromParent

() private chainable

Defined in src/vdom/partials/vnode.js:1275

Available since 0.0.1

Removes the vnode from its parent vChildNodes- and vChildren-list.

Does NOT sync with the dom.

_destroy

() private chainable

Defined in src/vdom/partials/vnode.js:1351

Available since 0.0.1

Destroys the vnode and all its vnode-vChildNodes. Removes it from its vParent.vChildNodes list,

Does NOT sync with the dom.

_findElementSibling

(
  • vnode
  • [next]
)
Object | Undefined private

Defined in src/vdom/partials/vnode.js:242

Available since 0.0.1

Searches for the next -or previous- Element-sibling (nodeType of 1).

Parameters:

  • vnode Object

    the vnode to inspect

  • [next] Boolean optional

    whether to search for the next, or previous match.

Returns:

Object | Undefined:

the vnode that matches the search

_findNodeSibling

(
  • vnode
  • [next]
)
Object | Undefined private

Defined in src/vdom/partials/vnode.js:221

Available since 0.0.1

Searches for the next -or previous- node-sibling (nodeType of 1, 3 or 8).

Parameters:

  • vnode Object

    the vnode to inspect

  • [next] Boolean optional

    whether to search for the next, or previous match.

Returns:

Object | Undefined:

the vnode that matches the search

_insertBefore

(
  • newVNode
  • refVNode
)
Node private

Defined in src/vdom/partials/vnode.js:1543

Available since 0.0.1

Inserts newVNode before refVNode.

Syncs with the DOM.

Parameters:

  • newVNode Vnode

    vnode to insert

  • refVNode Vnode

    The vnode before which newVNode should be inserted.

Returns:

Node:

the Node being inserted (equals domNode)

_matchesOneSelector

(
  • vnode
  • selector
  • [relatedVNode]
)
Boolean private

Defined in src/vdom/partials/vnode.js:324

Available since 0.0.1

Check whether the vnode matches the css-selector. the css-selector should be a single selector, not multiple, so it shouldn't contain a comma.

Parameters:

  • vnode Vnode

    the vnode to inspect

  • selector String

    the selector-item to check the match for

  • [relatedVNode] Vnode optional

    a related vnode where to selectors starting with >, ~ or + should be compared. If not specified, any of these three starting selector-characters will be ignored (leading to matching this first character).

Returns:

Boolean:

whether the vnode matches the css-selector

_matchesSelectorItem

(
  • vnode
  • selectorItem
)
Boolean private

Defined in src/vdom/partials/vnode.js:408

Available since 0.0.1

Check whether the vnode matches one specific selector-item. Suppose the css-selector: "#mynode li.red .blue" then there are 3 selector-items: "#mynode", "li.red" and ".blue"

This method also can handle the new selectors:

  • [att^=val] –-> the “begins with” selector
  • [att$=val] –-> the “ends with” selector
  • [att*=val] –-> the “contains” selector (might be a substring)
  • [att~=val] –-> the “contains” selector as a separate word, separated by spaces
  • [att|=val] –-> the “contains” selector as a separate word, separated by |
  • + --> (same level)
  • ~ --> (same level)

Parameters:

  • vnode Object

    the vnode to inspect

  • selectorItem String

    the selector-item to check the match for

Returns:

Boolean:

whether the vnode matches the selector-item

_matchNthChild

(
  • pseudoArg
  • index
)
Boolean private

Defined in src/vdom/partials/vnode.js:271

Available since 0.0.1

Check whether the vnode matches a "nth-child" test, which is used for css pseudoselectors like nth-child, nth-of-type etc.

Parameters:

  • pseudoArg String

    the argument for nth-child

  • index Number

    the index of the inspected vnode

Returns:

Boolean:

whether the vnode matches the nthChild test

_moveToParent

(
  • parentVNode
  • [index]
)
private chainable

Defined in src/vdom/partials/vnode.js:1585

Available since 0.0.1

Moves the vnode from its current parent.vChildNodes list towards a new parent vnode at the specified position.

Does NOT sync with the dom.

Parameters:

  • parentVNode Vnode

    the parent-vnode

  • [index] Number optional

    the position of the child. When not specified, it will be appended.

_normalizable

(
  • value
)
private chainable

Defined in src/vdom/partials/vnode.js:1651

Available since 0.0.1

Makes the vnode normalizable. Could be set to false when batch-inserting nodes, while normalizaing manually at the end. Afterwards, you should always reset normalizable to true.

Parameters:

  • value Boolean

    whether the vnode should be normalisable.

_normalize

() private chainable

Defined in src/vdom/partials/vnode.js:1611

Available since 0.0.1

Removes empty TextNodes and merges following TextNodes inside the vnode.

Syncs with the dom.

_noSync

() private chainable

Defined in src/vdom/partials/vnode.js:1667

Available since 0.0.1

Prevents MutationObserver from making the dom sync with the vnode. Should be used when manipulating the dom from within the vnode itself (to preventing looping)

_removeAttr

(
  • attributeName
)
private chainable

Defined in src/vdom/partials/vnode.js:1687

Available since 0.0.1

Removes the attribute of both the vnode as well as its related dom-node.

Syncs with the dom.

Parameters:

_replaceAtParent

(
  • newVNode
)
private chainable

Defined in src/vdom/partials/vnode.js:1755

Available since 0.0.1

Replaces the current vnode at the parent.vChildNode list by newVNode

Does NOT sync with the dom.

Parameters:

  • newVNode Object

    the new vnode which should take over the place of the current vnode

_setAttr

(
  • attributeName
  • value
  • [force=false]
)
private chainable

Defined in src/vdom/partials/vnode.js:1779

Available since 0.0.1

Sets the attribute of both the vnode as well as its related dom-node.

Syncs with the dom.

Parameters:

  • attributeName String
  • value String

    the value for the attributeName

  • [force=false] Boolean optional

    force the attribute to be set, even if restrictions would deny it

_setAttrs

(
  • newAttrs
)
private chainable

Defined in src/vdom/partials/vnode.js:1877

Available since 0.0.1

Redefines the attributes of both the vnode as well as its related dom-node. The new definition replaces any previous attributes (without touching unmodified attributes). the is attribute cannot be changed for itags.

Syncs the new vnode's attributes with the dom.

Parameters:

_setChildNodes

(
  • newVChildNodes
)
private chainable

Defined in src/vdom/partials/vnode.js:1945

Available since 0.0.1

Redefines the childNodes of both the vnode as well as its related dom-node. The new definition replaces any previous nodes. (without touching unmodified nodes).

Syncs the new vnode's childNodes with the dom.

Parameters:

  • newVChildNodes Array

    array with vnodes which represent the new childNodes

_splitSelector

(
  • selector
)
Array private

Defined in src/vdom/partials/vnode.js:781

Available since 0.0.1

Splits the selector into separate subselector-items that should match different elements through the tree. Special characters '>' and '+' are added as separate items in the hash.

Parameters:

  • selector String

    the selector-item to check the match for

Returns:

Array:

splitted selectors

_tryRemoveDomNode

(
  • parentDomNode
  • childDomNode
)

Defined in src/vdom/partials/vnode.js:875

Available since 0.0.1

A safe way to remove a dom-node, even if it is not present. Will not throw a JS error when the "to be removed" node isn't in the dom

Parameters:

  • parentDomNode DOMNode

    the parentNode that holds the node that needs to be removed

  • childDomNode DOMNode

    the node that needs to be removed

_tryReplaceChild

(
  • parentDomNode
  • newChildDomNode
  • oldChildDomNode
)

Defined in src/vdom/partials/vnode.js:895

Available since 0.0.1

A safe way to replace a dom-node, even if the "to be replaced"-node it is not present. Will not throw a JS error when the "to be replaced" node isn't in the dom. in that case, the new node will be appended

Parameters:

  • parentDomNode DOMNode

    the parentNode that holds the node that needs to be removed

  • newChildDomNode DOMNode

    the node that needs to be replaced

  • oldChildDomNode DOMNode

    the node that needs to be inserted

contains

() Boolean

Defined in src/vdom/partials/vnode.js:921

Available since 0.0.1

Check whether the vnode's domNode is equal, or contains the specified Element.

Returns:

Boolean:

whether the vnode's domNode is equal, or contains the specified Element.

empty

(
  • [full=false]
)
chainable

Defined in src/vdom/partials/vnode.js:942

Available since 0.0.1

Empties the vnode.

Syncs with the dom.

Parameters:

  • [full=false] Boolean optional

    whether system-nodes should be removed as well

firstOfVChildren

(
  • cssSelector
)
Object | Null

Defined in src/vdom/partials/vnode.js:957

Available since 0.0.1

Returns the first child-vnode (if any). The child represents an Element (nodeType===1).

Parameters:

  • cssSelector String

    one or more css-selectors

Returns:

Object | Null:

the first child-vnode or null when not present

getHTML

(
  • [exclude]
  • [includeSystemNodes=false]
)
String | Undefined

Defined in src/vdom/partials/vnode.js:980

Available since 0.0.1

Gets the innerHTML of the vnode representing the dom-node. You may exclude HTMLElement (node-type=1) by specifying exclude.

Only valid for nodetype=1 (HTMLElements)

Parameters:

  • [exclude] Array | HTMLElement optional

    an array of HTMLElements - or just 1 - to be excluded

  • [includeSystemNodes=false] Boolean optional

    whether system-nodes and i-tag inner-content should be returned. By default, they stay hidden.

Returns:

String | Undefined:

the innerHTML without the elements specified, or undefined when not an HTMLElement

getOuterHTML

(
  • [exclude]
  • [includeSystemNodes=false]
)
String

Defined in src/vdom/partials/vnode.js:1019

Available since 0.0.1

Gets the outerHTML of the vnode representing the dom-node. You may exclude HTMLElement (node-type=1) by specifying exclude.

Parameters:

  • [exclude] Array | HTMLElement optional

    an array of HTMLElements - or just 1 - to be excluded

  • [includeSystemNodes=false] Boolean optional

    whether system-nodes and i-tag inner-content should be returned. By default, they stay hidden.

Returns:

String:

the outerHTML

hasClass

(
  • className
)
Boolean

Defined in src/vdom/partials/vnode.js:1072

Available since 0.0.1

Checks whether the className is present on the vnode.

Parameters:

  • className String | Array

    the className to check for. May be an Array of classNames, which all needs to be present.

Returns:

Boolean:

whether the className (or classNames) is present on the vnode

hasVChildNodes

() Boolean

Defined in src/vdom/partials/vnode.js:1050

Available since 0.0.1

Checks whether the vnode has any vChildNodes (nodeType of 1, 3 or 8).

Returns:

Boolean:

whether the vnode has any vChildNodes.

hasVChildren

() Boolean

Defined in src/vdom/partials/vnode.js:1061

Available since 0.0.1

Checks whether the vnode has any vChildren (vChildNodes with nodeType of 1).

Returns:

Boolean:

whether the vnode has any vChildren.

lastOfVChildren

(
  • cssSelector
)
Object | Null

Defined in src/vdom/partials/vnode.js:1097

Available since 0.0.1

Returns the last child-vnode (if any). The child represents an Element (nodeType===1).

Parameters:

  • cssSelector String

    one or more css-selectors

Returns:

Object | Null:

the last child-vnode or null when not present

matchesSelector

(
  • selectors
  • [relatedVNode]
)
Boolean

Defined in src/vdom/partials/vnode.js:1120

Available since 0.0.1

Checks whether the vnode matches one of the specified selectors. selectors can be one, or multiple css-selectors, separated by a comma. For example: "#myid li.red blue" is one selector, "div.red, div.blue, div.green" are three selectors.

Parameters:

  • selectors String

    one or more css-selectors

  • [relatedVNode] Vnode optional

    a related vnode where to selectors starting with >, ~ or + should be compared. If not specified, any of these three starting selector-characters will be ignored (leading to matching this first character).

Returns:

Boolean:

whether the vnode matches one of the selectors

matchesSelector

(
  • attributeName
)
Node

Defined in src/vdom/partials/vnode.js:1144

Available since 0.0.1

Reloads the DOM-attribute into the vnode.

Parameters:

  • attributeName String

    the name of the attribute to be reloaded.

Returns:

Node:

the domNode that was reloaded.

removeChild

(
  • VNode
)
private

Defined in src/vdom/partials/vnode.js:1728

Available since 0.0.1

Removes the vnode's child-vnode from its vChildren and the DOM.

Syncs with the DOM.

Parameters:

  • VNode Vnode

    the child-vnode to remove

serializeStyles

() String

Defined in src/vdom/partials/vnode.js:1205

Available since 0.0.1

Returns the vnode's style in a serialized form: the way it appears in the dom.

Returns:

String:

vnode's style

setHTML

(
  • content
  • [suppressItagRender]
  • [allowScripts=false]
)
chainable

Defined in src/vdom/partials/vnode.js:1216

Available since 0.0.1

Sets the vnode's and dom-nodes inner HTML.

Syncs with the dom. Can be invoked multiple times without issues.

Parameters:

  • content String

    the innerHTML

  • [suppressItagRender] Boolean optional

    to suppress Itags from rendering

  • [allowScripts=false] Boolean optional

    whether scripts are allowed --> these should be defined with xscript instead of script

Properties

attrs

Object

Defined in src/vdom/partials/vnode.js:2237

Available since 0.0.1

A hash of all the attributes of the vnode's representing dom-node.

classNames

Object

Defined in src/vdom/partials/vnode.js:2245

Available since 0.0.1

Hash with all the classes of the vnode. Every class represents a key, all values are set true.

domNode

DomNode

Defined in src/vdom/partials/vnode.js:2305

Available since 0.0.1

The underlying dom-node that the vnode represents.

END_ATTRIBUTENAME

Object protected

Defined in src/vdom/partials/vnode.js:95

Available since 0.0.1

Object to gain quick access to attribute-name end-tokens.

Default: { '=': true, ']': true }

id

String

Defined in src/vdom/partials/vnode.js:2253

Available since 0.0.1

The id of the vnode's representing dom-node (if any).

innerHTML

String

Defined in src/vdom/partials/vnode.js:2322

Available since 0.0.1

Gets or sets the innerHTML of both the vnode as well as the representing dom-node.

The setter syncs with the DOM.

isVoid

Boolean

Defined in src/vdom/partials/vnode.js:2261

Available since 0.0.1

Tells whether tag is a void Element. Examples are: br, img and input. Non-void Elements are f.e. div and table. For TextNodes and CommentNodes, this property is undefined.

NODESWITCH

Object protected

Defined in src/vdom/partials/vnode.js:116

Available since 0.0.1

Object to gain quick access to different changes of Element nodeType changes.

Default: { 1: { 1: 1, 3: 2, 8: 3 }, 3: { 1: 4, 3: 5, 8: 6 }, 8: { 1: 7, 3: 8, 8: 9 } }

nodeType

Number

Defined in src/vdom/partials/vnode.js:2270

Available since 0.0.1

The nodeType of the vnode's representing dom-node (1===ElementNode, 3===TextNode, 8===CommentNode).

nodeValue

String

Defined in src/vdom/partials/vnode.js:2340

Available since 0.0.1

Gets or sets the innerHTML of both the vnode as well as the representing dom-node.

The setter syncs with the DOM.

outerHTML

String

Defined in src/vdom/partials/vnode.js:2367

Available since 0.0.1

Gets or sets the outerHTML of both the vnode as well as the representing dom-node.

The setter syncs with the DOM.

PSEUDO_REQUIRED_CHILDREN

Object protected

Defined in src/vdom/partials/vnode.js:187

Available since 0.0.1

Object to gain quick access to the selectors that required children

Default: { ':first-child': true, ':first-of-type': true, ':last-child': true, ':last-of-type': true, ':nth-child': true, ':nth-last-child': true, ':nth-last-of-type': true, ':nth-of-type': true, ':only-of-type': true, ':only-child': true }

SELECTOR_IDENTIFIERS

Object protected

Defined in src/vdom/partials/vnode.js:158

Available since 0.0.1

Object to gain quick access to selector start-tokens.

Default: { '#': 1, '.': 2, '[': 3 }

tag

String

Defined in src/vdom/partials/vnode.js:2278

Available since 0.0.1

The tag of the vnode's representing dom-node (allways uppercase).

text

String

Defined in src/vdom/partials/vnode.js:2286

Available since 0.0.1

The content of the vnode's representing dom-node, in case it is a TextNode or CommentNode. Equals dom-node.nodeValue.

Is undefined for ElementNodes.

textContent

String

Defined in src/vdom/partials/vnode.js:2446

Available since 0.0.1

Gets or sets the innerContent of the Node as plain text.

The setter syncs with the DOM.

vChildNodes

Array

Defined in src/vdom/partials/vnode.js:2297

Available since 0.0.1

Hash with all the childNodes (vnodes). vChildNodes are any kind of vnodes (nodeType===1, 3 or 8)

vChildren

Array

Defined in src/vdom/partials/vnode.js:2485

Available since 0.0.1

Hash with all the children (vnodes). vChildren are vnodes that have a representing dom-node that is an HtmlElement (nodeType===1)

vFirst

Vnode

Defined in src/vdom/partials/vnode.js:2511

Available since 0.0.1

Reference to the first of sibbling vNode's, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vFirstChild

Vnode

Defined in src/vdom/partials/vnode.js:2528

Available since 0.0.1

Reference to the first vChildNode, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vFirstElement

Vnode

Defined in src/vdom/partials/vnode.js:2541

Available since 0.0.1

Reference to the first of sibbling vNode's, where the related dom-node is an Element(nodeType===1).

vFirstElementChild

Vnode

Defined in src/vdom/partials/vnode.js:2558

Available since 0.0.1

Reference to the first vChild, where the related dom-node an Element (nodeType===1).

vLast

Vnode

Defined in src/vdom/partials/vnode.js:2571

Available since 0.0.1

Reference to the last of sibbling vNode's, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vLastChild

Vnode

Defined in src/vdom/partials/vnode.js:2588

Available since 0.0.1

Reference to the last vChildNode, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vLastElement

Vnode

Defined in src/vdom/partials/vnode.js:2602

Available since 0.0.1

Reference to the last of sibbling vNode's, where the related dom-node is an Element(nodeType===1).

vLastElementChild

Vnode

Defined in src/vdom/partials/vnode.js:2619

Available since 0.0.1

Reference to the last vChild, where the related dom-node an Element (nodeType===1).

vNext

Vnode

Defined in src/vdom/partials/vnode.js:2641

Available since 0.0.1

Reference to the next of sibbling vNode's, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vNextElement

Vnode

Defined in src/vdom/partials/vnode.js:2654

Available since 0.0.1

Reference to the next of sibbling vNode's, where the related dom-node is an Element(nodeType===1).

vParent

Vnode

Defined in src/vdom/partials/vnode.js:2313

Available since 0.0.1

vnode's parentNode (defined as a vnode itself).

vParent

Vnode

Defined in src/vdom/partials/vnode.js:2633

Available since 0.0.1

the Parent vnode

vPrevious

Vnode

Defined in src/vdom/partials/vnode.js:2667

Available since 0.0.1

Reference to the previous of sibbling vNode's, where the related dom-node is either an Element, TextNode or CommentNode (nodeType===1, 3 or 8).

vPreviousElement

Vnode

Defined in src/vdom/partials/vnode.js:2680

Available since 0.0.1

Reference to the previous of sibbling vNode's, where the related dom-node is an Element(nodeType===1).

Events

attributechange

Defined in src/vdom/partials/vnode.js:1475

Available since 0.1

Emitted by every Element that gets an attribute changed.

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating

    • changed Array

      Array with Objects having three properties:

      • attribute
      • newValue
      • prevValue

attributeinsert

Defined in src/vdom/partials/vnode.js:1449

Available since 0.1

Emitted by every Element that gets an attribute inserted.

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating

    • changed Array

      Array with Objects having three properties:

      • attribute
      • newValue

attributeremove

Defined in src/vdom/partials/vnode.js:1464

Available since 0.1

Emitted by every Element that gets an attribute removed.

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating

    • changed Array

      Array with Strings of the attributeNames that are removed

nodecontentchange

Defined in src/vdom/partials/vnode.js:1439

Available since 0.1

Emitted by every Element that gets its content changed (innerHTML/innerText).

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating

nodeinsert

Defined in src/vdom/partials/vnode.js:1419

Available since 0.1

Emitted by every Element that gets inserted.

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating

noderemove

Defined in src/vdom/partials/vnode.js:1429

Available since 0.1

Emitted by every Element that gets removed.

Event Payload:

  • e Object

    eventobject including:

    • target HtmlElement

      the HtmlElement that is being dragged

    • currentTarget HtmlElement

      the HtmlElement that is delegating