dome
v0.2.1
Published
A functional-ish DOM manipulation library.
Downloads
48
Readme
Dome
Dome is the DOM library part of Cull.JS, the functional JavaScript toolbelt for adults. Refer to Cull.JS for motivation behind our API design and the general underlying philosophy.
Function list
- children
(elements)
- id
(idStr)
- byClass
(className, parent)
- remove
(element)
- replace
(element, replacement)
- hasClassName
(className, element)
- addClassName
(cn, element)
- removeClassName
(cn, element)
- text
(elm)
- frag
(items)
- uuid
(object)
- contains
(element, child)
- setData
(data, element)
- getData
(property, element)
- setProp
(properties, element)
- append
(content, element)
- setContent
(children, element)
Documentation and examples
children (elements)
id (idStr)
byClass (className, parent)
remove (element)
replace (element, replacement)
var parent = dome.el("div", [dome.el("div")]);
var placeholder = parent.firstChild;
var el = dome.replace(placeholder, dome.el("p"));
assert.tagName(el, "p");
refute.same(parent.firstChild, placeholder);
hasClassName (className, element)
addClassName (cn, element)
removeClassName (cn, element)
text (elm)
var el = document.createElement("p");
el.innerHTML = "Hey there";
assert.equals(dome.text(el), "Hey there");
frag (items)
var frag = dome.frag();
assert.equals(frag.nodeType, 11);
uuid (object)
var object = {};
var id = dome.uuid(object);
assert.equals(id, dome.uuid(object));
assert.isNumber(id);
contains (element, child)
var parent = dome.el("div", [dome.el("div")]);
var child = parent.firstChild;
assert(dome.contains(parent, child));
setData (data, element)
getData (property, element)
setProp (properties, element)
append (content, element)
setContent (children, element)
Run tests
Either:
./node_modules/.bin/buster-server
Hit localhost:1111/capture and then:
./node_modules/.bin/buster-test
Or
npm test
Then hit localhost:8282
Contributors
- Martin Solli contributed bug fixes for Opera.
Thanks!
License
Copyright © 2012-2013, Christian Johansen and Magnar Sveen. Dome uses semantic versioning. Code released under the BSD license. Documentation released under CC Attribution-Share Alike.