On 8/2/2011 9:48 AM, Aryeh Gregor wrote:
On Mon, Aug 1, 2011 at 9:33 PM, Maciej Stachowiak<[email protected]>  wrote:
In an IRC discussion with Ian Hickson and Tab Atkins, we can up with the
following idea for convenient element creation:
Element.create(tagName, attributeMap, children…)
    Creates an element with the specified tag, attributes, and children.
How does this compare to popular JS helper libraries like jQuery?  It
would be useful to know what convenience APIs authors are using now
before introducing our own.


Here are three common helper libraries.

http://mootools.net/docs/core/Element/Element
var myAnchor = new Element('a', { href: 'http://mootools.net' });
// notes: namespacing requires escaping the colon \:
// moo enables: new Element('a.className') as a shorthand.
myAnchor.set({ key: val});
// styles and events are keywords.

http://dojotoolkit.org/documentation/tutorials/1.6/dom_functions/
http://dojotoolkit.org/api/1.6/dojo
var li = dojo.create("li", { innerHTML: "Six"});
// notes: dojo allows a third and fourth param to specify parent / child nodes and positioning.
dojo.attr(li,{key: val});

http://api.jquery.com/attr/
var myAnchor = $('<a href="http://api.jquery.com";>');
myAnchor.attr({key: val});
// attr also acts as a getter, when a string is passed, and a computed setter, when a function is used for a value.


Reply via email to