ampersand-dom
Minimal util-layer for applying transformations to DOM.
Still in a very in-progress-not-sure-if-this-is-a-good-idea type stage.
Still needs tests
It's a pretty thin layer on top of DOM apis, but should work crossbrowser (needs tests still).
It has zero dependencies.
install
npm install ampersand-dom
browser support
example
Here are all the methods and their usage:
var dom = require('ampersand-dom');
dom.text(el, 'set text content');
dom.addClass(el, 'someclass');
dom.removeClass(el, 'someclass');
dom.switchClass(el, 'oldclass', 'newclass');
dom.addAttribute(el, 'checked');
dom.removeAttribute(el, 'checked');
dom.setAttribute(el, 'value', 'the value');
dom.hide(el);
dom.show(el);
dom.html(el, '<div></div>');
credits
Initially created by @HenrikJoreteg with much inspiration/discussion with @philip_roberts.
license
MIT