Alias Library for the DOM API
The goal of domali is to provide a more readable DOM API while keeping the core functionality intact. You can use all of the native JavaScript DOM functions and objects with domali.
Usage
const foo bar baz = dom console
npm install --save domali
Install domali with npm jspm install domali
Or install domali with jspm Load domali through a module loader for the browser. Popular choices for module loading include webpack, jspm, and browserify. Destructuring requires ES6.
API
dom.getId (string) - Get an element by its id
const foo = dom
dom.getId (strings) - Get multiple elements by their ids
const foo bar baz = dom
dom.getClass (string) - Get multiple elements by their class name
const bar = dom
dom.getTags (string) - Get multiple elements by their tag name
const divs = dom
dom.select (string) - Select an element with a query
const foo = dom
dom.selectAll (string) - Select multiple elements with a query
const baz = dom
dom.create (string) - Create a new element
const div = dom console // true
dom.create (strings) - Create multiple new elements
const p a img = dom console // trueconsole // trueconsole // true
dom.clone (element) - Clone an existing element to a new element
const div = domtext'hey' const newDiv = dom console // <div>hey</div>
dom.render (element) - Render an element to the DOM
const div = domtext'Hello, domali!' dom
dom.clear () - Clear everything from the DOM
domclear
element.text (string) - Add or update an element's text
const div = domtext'hello' console // true
element.push (element) - Append a child element after an element's children
const div = dom divdivdiv console // true
element.unshift (element) - Insert a child element before an element's children
const div = dom divdivdiv console // true
element.map (fn (element)) - Transform an element's children
const rootDiv = dom rootDivrootDivrootDiv const newDiv = rootDiv console// <div>// <a></a>// <a></a>// <a></a>// </div>
element.set (object) - Set an element's attribute
const div = dom console // <div id="foo"></div>
element.get (string) - Get an element's attribute
const divId = dom console // foo
element.set (object) - Set multiple element attributes
const a = dom console // <a id="my-link" href="https://google.com" class="link"></a>
element.get (strings) - Get multiple element attributes
const imgId imgSrc imgClass = dom console // my-imageconsole // some-image.pngconsole // photo