Git Product home page Git Product logo

dome's Introduction

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

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

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.

dome's People

Contributors

cjohansen avatar henrik242 avatar magnars avatar msolli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dome's Issues

prepend

Prepending a dom element into a container is a hassle. Dome should help out.

Version 2.0 lost support for removing multiple classes at once

removeClassName used to work with removing multiple classes at once, however there is no unittest for it, so I guess it was not an intended feature... ;)

Anyways, changing the code:

function removeClassName(cn, element) {
    if (C.isList(element)) {
        return C.doall(C.partial(removeClassName, cn), element);
    }
    if (!hasClassName(cn, element)) { return; }
    var isCn = function (c) { return c === cn; };
    var classes = element.className.split(" ");
    element.className = C.reject(isCn, classes).join(" ");
}

To:

function removeClassName(cn, element) {
    if (C.isList(element)) {
        return C.doall(C.partial(removeClassName, cn), element);
    }
    var isCn = function (c) { return cn.indexOf(c) !== -1; };
    var classes = element.className.split(" ");
    element.className = C.reject(isCn, classes).join(" ");
}

Seems to provide this feature.

What do you think guys, should it support adding/removing multiple classes at once?

Value attribute on radio button elements not being set in Opera (in certain cases)

Hey yo

Consider this fiddle: http://jsfiddle.net/msolli/ybZkE/

Btw, this fiddle pulls in dome.js from FINN oppdrag dev environment, which @magnars would recognize. :)

Run it in Chrome, and everything is hunky dory. Run it in Opera (12.16 on Mac in my case), and radio2's value is not being set correctly. I suppose it has something to do with the order in which the properties are updated. Maybe 'type' always should be set before 'value' in setProp()? I don't know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.