W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2013

html template string handler WAS: E4H and constructing DOMs

From: Ojan Vafai <ojan@chromium.org>
Date: Mon, 11 Mar 2013 11:01:02 -0700
Message-ID: <CANMdWTu2mStea4hcBJhEjoJyKkx0YCttH1QNKa0QuDECa62=ZA@mail.gmail.com>
To: Adam Barth <w3c@adambarth.com>
Cc: Jonas Sicking <jonas@sicking.cc>, Domenic Denicola <domenic@domenicdenicola.com>, Allen Wirfs-Brock <allen@wirfs-brock.com>, Anne van Kesteren <annevk@annevk.nl>, Rick Waldron <waldron.rick@gmail.com>, Adam Klein <adamk@chromium.org>, Brendan Eich <brendan@secure.meer.net>, Ian Hickson <ian@hixie.ch>, "rafaelw@chromium.org" <rafaelw@chromium.org>, Alex Russell <slightlyoff@chromium.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>, "Mark S. Miller" <erights@google.com>
On Mon, Mar 11, 2013 at 10:22 AM, Adam Barth <w3c@adambarth.com> wrote:

> Is there a definition of the html quasis handler somewhere that I can
> study?
>

I don't believe there is. I think that's a whole separate discussion
really. Changing the subject line to match. I'm not really sure what spec
this would go in either. Perhaps it's own.

I see two options:
1. Do E4H style parsing. (http://www.hixie.ch/specs/e4h/strawman)
2. Do <template> style parsing through the regular HTML parser.

Both of these deal with the important case of creating a DOM that doesn't
have an appropriate context element at the root. Specifically,
html`<td>foo</td>` will work for both.

A difficult case is how you parse html`<a>foo</a>` because, without
context, you don't know if that element is an HTML element or an SVG
element. In either case, we'd need to add special syntax like the E4H
syntax for this.

So, the big trade-off is really static error checking versus consistency
with the rest of the platform. Is static error checking worth having the
html quasi parser parse things differently than innerHTML, <template>, etc.?

There are two main bits to E4H style parsing:
1. It doesn't do any fixup, e.g., if you misnest tags you get an error.
2. It allows you to create any DOM you could create from JS even though the
standard HTML parser wouldn't, e.g., html`<div><td>foo</td></div>` would
create exactly 3 nodes, a text node inside a table cell inside a div.

IMO, both of these are positives of E4H style parsing and are what I would
prefer to see happen. The inconsistency with the rest of the platform is
unfortunate, but is outweighed by the benefits.

Ojan
Received on Monday, 11 March 2013 18:01:56 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:09 UTC