1.0.2 • Published 7 years ago
Share package ndom A DOM wrapper with IntelliSense.
Installation npm install --save ndom
The UMD build is in the dist directory.
Short story Why not any of the others? Because I like this syntax more, actual property getters for every get operation. The collection of elements extends a real Array object so you get all the methods of the Array prototype.
Small code. Only necessary functions, maybe even missing some.
const ndom = require('ndom');
ndom('body').html = '<div id="div1">DIV IN BODY</div>';
ndom('#div1').html = '<a>l1</a><a>l2</a><a>l3</a>';
console.log(ndom('#div1').width, ndom('#div1').size.width === ndom('#div1').width);
console.log(ndom('#div1 a').html);
ndom('#div1 a').forEach((a, i) => {
console.log(a);
ndom(a).html += ' - <b>' + i + '</b>';
});
ndom('#div1 a').on('click', e => console.log('CLICK', e));
ndom('#div1 a').once('click', (e, node) => console.log('CLICK ONCE', node, e));
ndom('#div1 a').on('click', function(e) {
console.log('Binds to: ', this);
});
// etc...
Long story Classes
ndom
ndom(selector, parent )
ndom.match(el, selector) ⇒ boolean
ndom.onLoad(callback) ⇒ ndom Param Type callback function
ndom.onReady(callback) ⇒ ndom Param Type callback function
Collection ⇐ Array Kind : global classExtends: Array
collection.node ⇒ HTMLElement
collection.size ⇒ Object
collection.width ⇒ number
collection.height ⇒ number
collection.outerSize ⇒ Object
collection.offset ⇒ Object
collection.offsetParent ⇒ Collection
collection.offsetViewport ⇒ ClientRect
collection.position ⇒ Object
collection.left ⇒ number
collection.top ⇒ number
collection.html ⇒ string
collection.outerHtml ⇒ string
collection.text ⇒ string
collection.class ⇒ string
collection.classes ⇒ Array
collection.children ⇒ Collection
collection.length ⇒ number
collection.html
collection.text
collection.query(selector) ⇒ Collection Param Type selector string | Collection | HTMLElement | *
collection.queryParents(selector) ⇒ Collection Param Type selector string | Collection | HTMLElement | *
collection.contains(child) ⇒ boolean Param Type child string | Collection | HTMLElement | *
collection.clone() ⇒ Collection
collection.getAttr(name) ⇒ string | null
collection.hasClass(name) ⇒ boolean
collection.setAttr(name, value) ⇒ Collection Param Type name string value *
collection.addClass(name) ⇒ Collection
collection.removeClass(name) ⇒ Collection
collection.setHtml(html) ⇒ Collection
collection.setText(text) ⇒ Collection
collection.serialize(asObject ) ⇒ string | object
collection.append(children) ⇒ Collection Param Type children Collection | HTMLElement | Array | *
collection.prepend(children) ⇒ Collection
collection.remove() ⇒ Collection
collection.replace(html) ⇒ Collection Param Type html string | Collection | HTMLElement | *
collection.insertAfter(html) ⇒ Collection Param Type html string | Collection | HTMLElement | *
collection.insertBefore(html) ⇒ Collection Param Type html string | Collection | HTMLElement | *
collection.empty() ⇒ Collection
Param Type type string selector string | function handler function
Param Type type string selector string | function handler function
Param Type type string selector string | function handler function
collection.emit(eventName) ⇒ Collection
collection.dispatch(event) ⇒ Collection
Collection.wrap(collection, ndom, window) ⇒ Collection TODO Test test test.