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

Re: Simplifying element creation

From: Charles Pritchard <chuck@jumis.com>
Date: Tue, 4 Oct 2011 09:26:42 -0700
Message-Id: <2FCB54D1-71A1-4684-89CD-EBFB4502B5D0@jumis.com>
Cc: "www-dom@w3.org" <www-dom@w3.org>
To: João Eiras <joao.eiras@gmail.com>

On Oct 4, 2011, at 8:26 AM, João Eiras <joao.eiras@gmail.com> wrote:

>>>> E.g.<div>Hello<a href="/">World</a></div>  is represented as:
>>>>  ["div", "Hello ", ["a", {href:"/"}, "World"]]
> I consider using html fragments instead of json-like representations
> for bulk element creation more optimal. It's non-ambiguous and doesn't
> require many intermediate temporary objects, which just add
> unnecessary overhead, because they would have to be created,
> traversed, sanatized (handling getters and setters, or properties with
> unexpected types), while the html parser does one pass (in an ideal
> situation) and creates everything in one go.

It's the process of stringifying an existing JS object structure that's motivating this discussion.

It's much more natural to program and manipulate a JS object than a string.

These examples are using strings, but in the real world, we're using variables and method calls. It's more efficient for the coder and the implementation to go from JS object to DOM than to have a middle step of JS to XML DOMString to DOM.
Received on Tuesday, 4 October 2011 16:27:13 UTC

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