W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2011

Re: Simplifying element creation

From: Roland Steiner <rolandsteiner@google.com>
Date: Wed, 5 Oct 2011 10:01:22 +0900
Message-ID: <CACFPSphtdFVqof+yd7Jg07TsjkphhBRcm8r7YCpY8m2WO49mxg@mail.gmail.com>
To: Ojan Vafai <ojan@chromium.org>
Cc: Dominic Cooney <dominicc@chromium.org>, Anne van Kesteren <annevk@opera.com>, "www-dom@w3.org" <www-dom@w3.org>
On Wed, Oct 5, 2011 at 9:39 AM, Ojan Vafai <ojan@chromium.org> wrote:

> Given ES6 spread, I don't think we need to allow NodeList or Array. Not
> allowing arrays also means we avoid the issue that Roland brought up because
> the first string in any array is an element name and not text and only the
> first string in an array is an element name.
> For example:
> foo.append('div'); // appends the string 'div' to foo as a text node
> foo.append(['div']); // appends a div element to foo

That seems reasonable. Conversely, being strict about this means

['style', 'scoped']

is not equivalent to <style scoped>, neither equivalent to
<style>scoped</style>, but simply an error (that throws, I presume?).

> Element.create(['div', {}, {'onclick': 'return false;', 'onmousedown':
> function() {}}]);

Probably this has been brought up before, but what prevents event handlers
from being put together with regular attributes (which I'm sure people will
try), by design or by error? E.g.,

['div', {'style': 'background-color: red'; color: white, 'onclick':

Conversely, why the requirement to have 2 different entries for those?
Conceptually, when writing <div style="color:red" onclick="clicky()"> there
isn't a distinction either.


- Roland
Received on Wednesday, 5 October 2011 01:02:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:36:59 UTC