W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

Re: Implied Context Parsing (DocumentFragment.innerHTML, or similar) proposal details to be sorted out

From: Henri Sivonen <hsivonen@iki.fi>
Date: Mon, 18 Jun 2012 17:25:42 +0300
Message-ID: <CAJQvAudzkLnu38yS=fG13beSC_p0ZiECXznMHewSYQb=E6G78g@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Scott González <scott.gonzalez@gmail.com>, Rafael Weinstein <rafaelw@google.com>, Webapps WG <public-webapps@w3.org>, "Tab Atkins Jr." <jackalmage@gmail.com>, Yehuda Katz <wycats@gmail.com>, Ryosuke Niwa <rniwa@webkit.org>
On Sat, Jun 16, 2012 at 3:23 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> On Jun 11, 2012 2:06 PM, "Henri Sivonen" <hsivonen@iki.fi> wrote:
>>
>> On Fri, Jun 8, 2012 at 11:03 PM, Yehuda Katz <wycats@gmail.com> wrote:
>> > It's intentional. If you look at the implementation, we explicitly
>> > extract
>> > the <script> tags and use our globalEval implementation to execute them.
>>
>> Okay. Let's make document.parse() make scripts executable, then, for
>> consistency with what script libraries want. I think it will be a
>> total foot gun when a fragment contains more than one script, though.
>
> Just so everyone vi för the same page, this means that <script> elements
> will stay vi the DOM where they appear in the markup, but won't execute
> before document.parse returns. Once the DOM fragment vi inserted inline
> <script>s will sychronously execute in depth-first order. They execute after
> the whole fragment has been inserted, but before the insertion function has
> returned.
>
> Correct?

Yes, at least to the extent there are no nested script elements. SVG
scripts can nest even in parser output and
http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1596 shows
that Chrome and IE10 agree with each other and with what you say.
Firefox disagrees when it comes to nested scripts. Opera seems to
gather the program text incorrectly. It seems to try to use
.textContent instead of the concatenation of child text nodes.

The foot gun part that I referred to was about external scripts. Those
run asynchronously and in unpredictable order. I think we should keep
it that way, but I think it's a terrible idea to execute scripts by
inserting a fragment that contains multiple external scripts or an
external script followed by an in-line script, because those cases
don't behave as in document.write, which is why, absent the jQuery
precedent, I would have preferred to make document.parse completely
useless for running scripts.

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/
Received on Monday, 18 June 2012 14:26:06 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT