Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Jonas Sicking
On Mon, Aug 8, 2011 at 9:17 AM, Tab Atkins Jr. wrote: > On Mon, Aug 8, 2011 at 1:17 AM, Jonas Sicking wrote: >> Is there a reason to support namespaced attributes at all? They are >> extremely rare, especially on the web. >> >> Ideally I'd like to deprecate them, but I suspect that's not doable.

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Tab Atkins Jr.
On Mon, Aug 8, 2011 at 1:17 AM, Jonas Sicking wrote: > Is there a reason to support namespaced attributes at all? They are > extremely rare, especially on the web. > > Ideally I'd like to deprecate them, but I suspect that's not doable. > But I see no reason to support them in new APIs. SVG requi

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Julian Reschke
On 2011-08-08 11:34, Jonas Sicking wrote: ... First off, that's infinitely more work to support a rarely used feature than not supporting it at all. Second, since that notation isn't used anywhere else, it's a pretty big cost in brain print for users. So no, I wouldn't say it's cheap. ... Wel

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Jonas Sicking
On Mon, Aug 8, 2011 at 2:17 AM, Julian Reschke wrote: > On 2011-08-08 10:17, Jonas Sicking wrote: >> >> On Mon, Aug 8, 2011 at 12:52 AM, Tab Atkins Jr. >>  wrote: >>> >>> On Sat, Aug 6, 2011 at 9:05 AM, Dominic Cooney >>>  wrote: Third, is the order of attributes significant for XML name

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Julian Reschke
On 2011-08-08 10:17, Jonas Sicking wrote: On Mon, Aug 8, 2011 at 12:52 AM, Tab Atkins Jr. wrote: On Sat, Aug 6, 2011 at 9:05 AM, Dominic Cooney wrote: Third, is the order of attributes significant for XML namespace declarations? eg does this: mean the same thing as ? If not, including names

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Garrett Smith
On 8/6/11, Charles Pritchard wrote: [...] > I've stated in prior threads, that unless the word is aria-* or data-*, > properties are set on the element. I see. But that's inherently inconsistent and mostly misleading ("attr" alludes to "attribute" not "usually property except when it's data or ari

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Jonas Sicking
On Mon, Aug 8, 2011 at 12:52 AM, Tab Atkins Jr. wrote: > On Sat, Aug 6, 2011 at 9:05 AM, Dominic Cooney wrote: >> Third, is the order of attributes significant for XML namespace >> declarations? eg does this: >> >> mean the same thing as >> >> ? If not, including namespaces in the attribute dic

Re: Element.create(): a proposal for more convenient element creation

2011-08-08 Thread Tab Atkins Jr.
On Sat, Aug 6, 2011 at 9:05 AM, Dominic Cooney wrote: > Third, is the order of attributes significant for XML namespace > declarations? eg does this: > > mean the same thing as > > ? If not, including namespaces in the attribute dictionary is fraught, > because the iteration order of properties

Re: Element.create(): a proposal for more convenient element creation

2011-08-06 Thread Charles Pritchard
On 8/6/2011 3:54 PM, Garrett Smith wrote: On 8/6/11, Charles Pritchard wrote: On 8/6/2011 9:05 AM, Dominic Cooney wrote: Element.create looks neat. Three thoughts: ... Let me briefly reiterate that I think we want *both* Element.create and constructors; they have complementary uses. I agree

Re: Element.create(): a proposal for more convenient element creation

2011-08-06 Thread Garrett Smith
On 8/6/11, Charles Pritchard wrote: > On 8/6/2011 9:05 AM, Dominic Cooney wrote: >> Element.create looks neat. Three thoughts: > ... >> Let me briefly reiterate that I think we want *both* Element.create >> and constructors; they have complementary uses. > I agree. And for no reason, it seems. >

Re: Element.create(): a proposal for more convenient element creation

2011-08-06 Thread Charles Pritchard
On 8/6/2011 9:05 AM, Dominic Cooney wrote: Element.create looks neat. Three thoughts: ... Let me briefly reiterate that I think we want *both* Element.create and constructors; they have complementary uses. I agree. Second, re: setAttribute vs setting properties, there might be types other

Re: Element.create(): a proposal for more convenient element creation

2011-08-06 Thread Dominic Cooney
Element.create looks neat. Three thoughts: First, I think Element.create *and* constructors like new HTMLDivElement(attributes, children) are both useful. Element.create is good when you have a tag name in hand, are creating unknown elements, or are creating elements that don’t have a specific con

Re: Element.create(): a proposal for more convenient element creation

2011-08-04 Thread Garrett Smith
On 8/4/11, Garrett Smith wrote: [...] ser-generated function function. > > The scope of handler attributes is explained in HTML 5, though > incompletely: > http://dev.w3.org/html5/spec/Overview.html#event-handler-content-attributes > That's incomplete. > Correction: It is complete, I just misread

Re: Element.create(): a proposal for more convenient element creation

2011-08-04 Thread Garrett Smith
On 8/4/11, Jonas Sicking wrote: > On Wed, Aug 3, 2011 at 8:10 AM, Tab Atkins Jr. wrote: >> On Wed, Aug 3, 2011 at 12:34 AM, Anne van Kesteren >> wrote: >>> On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. >>> wrote: On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: > On Tue, Aug

Re: Element.create(): a proposal for more convenient element creation

2011-08-04 Thread Jonas Sicking
On Wed, Aug 3, 2011 at 8:10 AM, Tab Atkins Jr. wrote: > On Wed, Aug 3, 2011 at 12:34 AM, Anne van Kesteren wrote: >> On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. >> wrote: >>> On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. w

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Charles Pritchard
On 8/3/2011 8:51 AM, Anne van Kesteren wrote: On Wed, 03 Aug 2011 17:46:50 +0200, Glenn Maynard wrote: What's the difference? ele.setAttribute(x, val) works on any element. ele[x] = val does not. They also behave differently for a large number of cases and the latter often takes values of a

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Tab Atkins Jr.
On Wed, Aug 3, 2011 at 12:34 AM, Anne van Kesteren wrote: > On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. > wrote: >> On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: >>> On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. >>> wrote: MooTools is basically identical to Prototype, excep

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Glenn Maynard
On Wed, Aug 3, 2011 at 11:50 AM, Tab Atkins Jr. wrote: > for(key in attrs) a.setAttribute(key,attrs[key]); > > This would obviously produce a different result here, as the function > would be stringified into something useless. > I think that means it's the wrong thing to do. Within JavaScript c

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Anne van Kesteren
On Wed, 03 Aug 2011 17:46:50 +0200, Glenn Maynard wrote: What's the difference? ele.setAttribute(x, val) works on any element. ele[x] = val does not. They also behave differently for a large number of cases and the latter often takes values of a type other than DOMString. I'd expect th

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Tab Atkins Jr.
On Wed, Aug 3, 2011 at 8:46 AM, Glenn Maynard wrote: > On Wed, Aug 3, 2011 at 3:34 AM, Anne van Kesteren wrote: >> On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. >> wrote: >>> Hmm, is everything exposed as on* attributes now?  If so, then yeah, >>> just do that; no need to mess around with a

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Glenn Maynard
On Wed, Aug 3, 2011 at 3:34 AM, Anne van Kesteren wrote: > On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. > wrote: > >> Hmm, is everything exposed as on* attributes now? If so, then yeah, >> just do that; no need to mess around with a magic property in the >> attributes bag. >> > > This wou

Re: Element.create(): a proposal for more convenient element creation

2011-08-03 Thread Anne van Kesteren
On Tue, 02 Aug 2011 20:31:04 +0200, Tab Atkins Jr. wrote: On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. wrote: MooTools is basically identical to Prototype, except that you can additionally set listeners on the element during creation

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Garrett Smith
On 8/2/11, Tab Atkins Jr. wrote: > On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: >> On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. >> wrote: >>> MooTools is basically identical to Prototype, except that you can >>> additionally set listeners on the element during creation by using a >>>

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Tab Atkins Jr.
On Tue, Aug 2, 2011 at 11:26 AM, Glenn Maynard wrote: > On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. wrote: >> MooTools is basically identical to Prototype, except that you can >> additionally set listeners on the element during creation by using a >> magical "events" property in the attribute

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Garrett Smith
On 8/2/11, Tab Atkins Jr. wrote: > On Tue, Aug 2, 2011 at 9:48 AM, Aryeh Gregor wrote: >> On Mon, Aug 1, 2011 at 9:33 PM, Maciej Stachowiak wrote: >>> In an IRC discussion with Ian Hickson and Tab Atkins, we can up with the >>> following idea for convenient element creation: >>> Element.create(t

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Glenn Maynard
On Tue, Aug 2, 2011 at 2:18 PM, Tab Atkins Jr. wrote: > MooTools is basically identical to Prototype, except that you can > additionally set listeners on the element during creation by using a > magical "events" property in the attribute bag, which takes an object > of event names and functions.

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Aryeh Gregor
On Tue, Aug 2, 2011 at 2:05 PM, Tab Atkins Jr. wrote: > Read again - the idea is to auto-expand arrays. > > (I don't have much of a preference between "just use an array" and > "use varargs, but expand arrays".  I agree that using only varargs > without expansion would be bad.) I'm against "use v

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Tab Atkins Jr.
On Tue, Aug 2, 2011 at 9:48 AM, Aryeh Gregor wrote: > On Mon, Aug 1, 2011 at 9:33 PM, Maciej Stachowiak 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…) >>    C

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Charles Pritchard
On 8/2/2011 9:48 AM, Aryeh Gregor wrote: On Mon, Aug 1, 2011 at 9:33 PM, Maciej Stachowiak 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

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Tab Atkins Jr.
On Tue, Aug 2, 2011 at 12:36 AM, Jonas Sicking wrote: > I'm not sure if it's better to include the children as a var-args > list, or as an array. Certainly when typing things normally var-args > saves you the "[" and "]", but when coding, if you've built the child > list dynamically and have an ar

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Dimitri Glazkov
On Tue, Aug 2, 2011 at 10:37 AM, Ian Hickson wrote: > On Tue, 2 Aug 2011, Dimitri Glazkov wrote: >> On Tue, Aug 2, 2011 at 1:27 AM, Roland Steiner >> wrote: >> > On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking >> > wrote: >> >> This doesn't explain why a factory method is better than explicit >> >

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Ian Hickson
On Tue, 2 Aug 2011, Dimitri Glazkov wrote: > On Tue, Aug 2, 2011 at 1:27 AM, Roland Steiner > wrote: > > On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking > > wrote: > >> This doesn't explain why a factory method is better than explicit > >> constructors though? The above could be written as > >>

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Aryeh Gregor
On Mon, Aug 1, 2011 at 9:33 PM, Maciej Stachowiak 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 c

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Dimitri Glazkov
On Tue, Aug 2, 2011 at 1:27 AM, Roland Steiner wrote: > On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking wrote: >> This doesn't explain why a factory method is better than explicit >> constructors though? The above could be written as >> >> new HTMLParagraphElement(null, "foo", ...); > > It's not a

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Dimitri Glazkov
On Tue, Aug 2, 2011 at 1:27 AM, Roland Steiner wrote: > On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking wrote: >> This doesn't explain why a factory method is better than explicit >> constructors though? The above could be written as >> >> new HTMLParagraphElement(null, "foo", ...); > > It's not a

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Roland Steiner
On Tue, Aug 2, 2011 at 4:36 PM, Jonas Sicking wrote: > This doesn't explain why a factory method is better than explicit > constructors though? The above could be written as > > new HTMLParagraphElement(null, "foo", ...); It's not a general use case, but at least when it comes to XBL-like compone

Re: Element.create(): a proposal for more convenient element creation

2011-08-02 Thread Jonas Sicking
On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak 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

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Charles Pritchard
On Aug 1, 2011, at 9:25 PM, Ian Hickson wrote: > On Tue, 2 Aug 2011, João Eiras wrote: >> >> While the idea is interesting, "create" is a too simple name to add on >> something as polluted as Element. > > Why? > > I think create() is fine. It's a pretty common name for a factory or > constru

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Maciej Stachowiak
On Aug 1, 2011, at 8:43 PM, Tab Atkins Jr. wrote: > On Mon, Aug 1, 2011 at 7:05 PM, Charles Pritchard wrote: >> Can we have it 'inherit' a parent namespace, and have chaining properties? >> >> Element.create('div').create('svg').create('g').create('rect', {title: 'An >> svg rectangle in an HTM

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Maciej Stachowiak
On Aug 1, 2011, at 8:36 PM, João Eiras wrote: > On , Ian Hickson wrote: > >> On Mon, 1 Aug 2011, Ryosuke Niwa wrote: >>> On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak wrote: >>> > >>> > In an IRC discussion with Ian Hickson and Tab Atkins, we can up with >>> > the following idea for conven

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Ian Hickson
On Tue, 2 Aug 2011, João Eiras wrote: > > While the idea is interesting, "create" is a too simple name to add on > something as polluted as Element. Why? I think create() is fine. It's a pretty common name for a factory or constructor (in languages with named constructors), and having it on th

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Ian Hickson
On Tue, 2 Aug 2011, João Eiras wrote: > > However, Nodes need a ownerDocument, and that needs to be supplied, even > if optionally. Doing document.createElement implies the document, > Element.create does not. Just use the same document as new Image(), new Option(), or new Audio(). -- Ian Hic

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Tab Atkins Jr.
On Mon, Aug 1, 2011 at 8:52 PM, João Eiras wrote: > On , Tab Atkins Jr. wrote: > >> On Mon, Aug 1, 2011 at 7:05 PM, Charles Pritchard wrote: >>> >>> Can we have it 'inherit' a parent namespace, and have chaining >>> properties? >>> >>> Element.create('div').create('svg').create('g').create('rect

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread João Eiras
On , Tab Atkins Jr. wrote: On Mon, Aug 1, 2011 at 7:05 PM, Charles Pritchard wrote: Can we have it 'inherit' a parent namespace, and have chaining properties? Element.create('div').create('svg').create('g').create('rect', {title: 'An svg rectangle in an HTML div'}); Ooh, so .create is def

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Tab Atkins Jr.
On Mon, Aug 1, 2011 at 7:05 PM, Charles Pritchard wrote: > Can we have it 'inherit' a parent namespace, and have chaining properties? > > Element.create('div').create('svg').create('g').create('rect', {title: 'An > svg rectangle in an HTML div'}); Ooh, so .create is defined both on Element (defa

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Cameron McCormack
On 2/08/11 3:36 PM, João Eiras wrote: However, Nodes need a ownerDocument, and that needs to be supplied, even if optionally. Doing document.createElement implies the document, Element.create does not. I figure the ownerDocument would be window.document (where the window object is the global o

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread João Eiras
On , Ian Hickson wrote: On Mon, 1 Aug 2011, Ryosuke Niwa wrote: On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak 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, chi

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Dimitri Glazkov
On Mon, Aug 1, 2011 at 6:43 PM, Ian Hickson wrote: > On Mon, 1 Aug 2011, Maciej Stachowiak wrote: >> >>    Creates an element with the specified tag, attributes, and children. >> >>    tagName - tag name as a string; by default it does "smart" selection >> of SVG, HTML or MathML namespace. Authors

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Ian Hickson
On Mon, 1 Aug 2011, Ryosuke Niwa wrote: > On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak 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�) > > Can

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Charles Pritchard
On Aug 1, 2011, at 6:43 PM, Ian Hickson wrote: > On Mon, 1 Aug 2011, Maciej Stachowiak wrote: >> >> Creates an element with the specified tag, attributes, and children. >> >> tagName - tag name as a string; by default it does "smart" selection >> of SVG, HTML or MathML namespace. Autho

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Ryosuke Niwa
On Mon, Aug 1, 2011 at 6:33 PM, Maciej Stachowiak 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…) > Can we alternatively extend document.createElement? Or wa

Re: Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Ian Hickson
On Mon, 1 Aug 2011, Maciej Stachowiak wrote: > >Creates an element with the specified tag, attributes, and children. > >tagName - tag name as a string; by default it does "smart" selection > of SVG, HTML or MathML namespace. Authors can also use an html: svg: or > mathml: prefix to over

Element.create(): a proposal for more convenient element creation

2011-08-01 Thread Maciej Stachowiak
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. tagName - tag name as a string; by default it doe