YumJS _createNode Documentation

Creating a Node


You can create new nodes with _createNode().


let newnode = yum()._createNode('div');
yum(newnode).prependTo('.blurb').text('I am newnode');

Any node type not in the following list will default to a node type of div unless 2nd parameter is set to true.

Supported default node types:

['html', 'head', 'link', 'meta', 'script', 'style', 'title', 'body', 'article', 'aside', 'footer', 'header', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'main', 'nav', 'section', 'blockquote', 'div', 'figure', 'hr', 'li', 'ol', 'p', 'pre', 'ul', 'a', 'code', 'data', 'time', 'em', 'i', 'span', 'strong', 'audio', 'source', 'img', 'track', 'video', 'iframe', 'canvas', 'noscript', 'col', 'colgroup', 'button', 'option', 'fieldset', 'label', 'form', 'input', 'select', 'textarea', 'menu', 'template'];

You can specify non-standard node types (not a good idea) by setting the 2nd parameter to _createNode to true.

If you know the type of the node you are creating is a valid node type but is just not in the list above, set the 2nd parameter to true.


let fakenode = yum()._createNode('fake');//works but defaults to type div
yum(fakenode).prependTo('.body').text('I am fakenode');

//works but is not a valid node. 
//Do this only when you know the type is valid.

let fakenode = yum()._createNode('fake', true);
yum(fakenode).prependTo('.body').text('I am fakenode');

If you have any questions about Yum please contact me.