<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>24042</bug_id>
          
          <creation_ts>2013-12-09 22:49:17 +0000</creation_ts>
          <short_desc>[imports]: Parser should not wait on external resources inside imports</short_desc>
          <delta_ts>2015-07-06 08:08:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>MOVED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>24808</dependson>
          <blocked>23278</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Elliott Sprehn">esprehn</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>adamk</cc>
    
    <cc>annevk</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>mike</cc>
    
    <cc>morrita</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97360</commentid>
    <comment_count>0</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-12-09 22:49:17 +0000</bug_when>
    <thetext>The HTML parser should continue tree building inside an import even if blocked on an external resource.

As a result document.write() should also throw when the currentScript is inside an import since the location of the write is arbitrary.

The result of this is that given:

&lt;link rel=&quot;import&quot; href=&quot;1.html&quot;&gt;
&lt;script src=&quot;slow.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;import&quot; href=&quot;2.html&quot;&gt;
&lt;link rel=&quot;import&quot; href=&quot;3.html&quot;&gt;
&lt;x-foo&gt;&lt;/x-foo&gt;
&lt;script&gt;
  console.log(1);
&lt;/script&gt;

While slow.js is being downloaded the entire import tree (1.html, 2.html and 3.html) can be processed and constructed into DOM trees. When it finishes loading the scripts that were queued while tree building these nested imports and the top level import with the console.log should be executed in order. This is conceptually similar to defer@ or async@ on &lt;script&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97366</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-12-10 02:53:10 +0000</bug_when>
    <thetext>It&apos;s not just document.write, is it?

When slow.js runs, can it tell whether 2.html has been loaded?  If so, it&apos;ll see a somewhat non-deterministic view of the DOM...

I guess @async scripts have some of that behavior too, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97367</commentid>
    <comment_count>2</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-12-10 03:00:30 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #1)
&gt; It&apos;s not just document.write, is it?
&gt; 
&gt; When slow.js runs, can it tell whether 2.html has been loaded?  If so, it&apos;ll
&gt; see a somewhat non-deterministic view of the DOM...
&gt; 
&gt; I guess @async scripts have some of that behavior too, though.

Yes, @async already has this behavior.

You will always have a non-deterministic view of the main document from an import since it doesn&apos;t block the parser as we treat imports like stylesheets not script when parsing. We&apos;re extending that behavior to the entire import tree.

The reason to throw in document.write() is that it prevents depending on the tokens being inserted in any particular place. I&apos;m not sure why &lt;script async&gt; doesn&apos;t throw when you document.write(), we probably should have made it do so.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97369</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2013-12-10 03:09:11 +0000</bug_when>
    <thetext>&gt; I&apos;m not sure why &lt;script async&gt; doesn&apos;t throw when you document.write()

It just silently does nothing instead, presumably because that&apos;s less likely to totally break preexisting scripts that someone asyncfiies.

Which is also what document.write() does on a random document that&apos;s not being shown, actually.

The only case right now in which document.write() throws is if the document is XML.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97370</commentid>
    <comment_count>4</comment_count>
    <who name="Elliott Sprehn">esprehn</who>
    <bug_when>2013-12-10 03:43:25 +0000</bug_when>
    <thetext>(In reply to Boris Zbarsky from comment #3)
&gt; &gt; I&apos;m not sure why &lt;script async&gt; doesn&apos;t throw when you document.write()
&gt; 
&gt; It just silently does nothing instead, presumably because that&apos;s less likely
&gt; to totally break preexisting scripts that someone asyncfiies.
&gt; 

I&apos;m fine if we make this a no-op in imports to match that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100233</commentid>
    <comment_count>5</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2014-02-11 01:03:38 +0000</bug_when>
    <thetext>Renaming the subject to reflect the discussion, and land the fix.

https://github.com/w3c/webcomponents/commit/3a2ac114606bb80df5aa5aae047ae3342cc06339</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100266</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-11 13:14:42 +0000</bug_when>
    <thetext>Please file bugs https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WHATWG&amp;component=HTML to make sure this gets properly integrated and reviewed by the editor of the HTML specification. Monkey patching without actually involving Ian is not the right way to go about this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100267</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-11 13:16:00 +0000</bug_when>
    <thetext>Also, your fix seems wrong. What if I had changed currentScript to throw on getting?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100313</commentid>
    <comment_count>8</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2014-02-11 19:32:24 +0000</bug_when>
    <thetext>(In reply to Anne from comment #6)
&gt; Please file bugs
&gt; https://www.w3.org/Bugs/Public/enter_bug.cgi?product=WHATWG&amp;component=HTML
&gt; to make sure this gets properly integrated and reviewed by the editor of the
&gt; HTML specification. Monkey patching without actually involving Ian is not
&gt; the right way to go about this.

(In reply to Anne from comment #7)
&gt; Also, your fix seems wrong. What if I had changed currentScript to throw on
&gt; getting?

Thanks for the catch. Will file a bug.
The discussion will lead the right way to spec this.
Would you mind to drop some link to the bug which asks this kind of thing?
I&apos;d like to learn how to discuss monkey patch in HTML land.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100390</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2014-02-12 11:22:05 +0000</bug_when>
    <thetext>I see you filed the bug yourself, thanks!

In general we should avoid monkey patching. 1) A specification may not be aware of the patches being applied and invalidate them. 2) Readers of a specification may not be aware of the patches being applied and write code that turns out to be wrong due to patches. 3) If patches start getting applied from multiple sources the mental model quickly becomes too hard and mistakes start creeping in all over.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100421</commentid>
    <comment_count>10</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2014-02-12 18:33:41 +0000</bug_when>
    <thetext>(In reply to Anne from comment #9)

&gt; In general we should avoid monkey patching. 1) A specification may not be
&gt; aware of the patches being applied and invalidate them. 2) Readers of a
&gt; specification may not be aware of the patches being applied and write code
&gt; that turns out to be wrong due to patches. 3) If patches start getting
&gt; applied from multiple sources the mental model quickly becomes too hard and
&gt; mistakes start creeping in all over.

Agreed.

We have some more monkey patches in the import spec.
I filed Bug 24632 to track these.
Although I&apos;m not sure if we can completely get rid of them,
it will be good idea to make these glitches visible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100651</commentid>
    <comment_count>11</comment_count>
    <who name="Adam Klein">adamk</who>
    <bug_when>2014-02-14 23:09:43 +0000</bug_when>
    <thetext>http://www.whatwg.org/specs/web-apps/current-work/#execute-the-script-block step 2.3 seems like the thing that needs to be fixed (the ignore-destructive-writes-counter needs to be incremented for imported scripts).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101361</commentid>
    <comment_count>12</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2014-02-25 18:46:25 +0000</bug_when>
    <thetext>Recovering the original summary line.
Will file new one for document.write() thing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>103892</commentid>
    <comment_count>13</comment_count>
    <who name="Morrita Hajime">morrita</who>
    <bug_when>2014-04-15 18:16:55 +0000</bug_when>
    <thetext>Moving this to future considerations. 

The source of incompatibility risk (Bug 24808) is killed, 
so it&apos;s safe to postpone this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>121671</commentid>
    <comment_count>14</comment_count>
    <who name="Hayato Ito">hayato</who>
    <bug_when>2015-07-06 08:08:09 +0000</bug_when>
    <thetext>Moved to https://github.com/w3c/webcomponents/issues/221</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>