W3C home > Mailing lists > Public > public-html-commits@w3.org > October 2010

html5/spec Overview.html,1.4491,1.4492

From: Ian Hickson via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 12 Oct 2010 21:20:43 +0000
To: public-html-commits@w3.org
Message-Id: <E1P5mH5-0003PA-HO@lionel-hutz.w3.org>
Update of /sources/public/html5/spec
In directory hutz:/tmp/cvs-serv13071

Modified Files:
Log Message:
Change how document.write() is ignored. (whatwg r5616)

Index: Overview.html
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.4491
retrieving revision 1.4492
diff -u -d -r1.4491 -r1.4492
--- Overview.html	12 Oct 2010 10:15:50 -0000	1.4491
+++ Overview.html	12 Oct 2010 21:20:39 -0000	1.4492
@@ -10103,23 +10103,35 @@
-    <p>Adds the given string(s) to the <code><a href="#document">Document</a></code>'s input
-    stream. If necessary, calls the <code title="dom-document-open"><a href="#dom-document-open">open()</a></code> method implicitly
-    first.</p>
+    <p>In general, adds the given string(s) to the
+    <code><a href="#document">Document</a></code>'s input stream.</p>
+    <p class="warning">This method has very idiosyncratic behavior. In
+    some cases, this method can affect the state of the <a href="#html-parser">HTML
+    parser</a> while the parser is running, resulting in a DOM that
+    does not correspond to the source of the document. In other cases,
+    the call can clear the current page first, as if <code title="dom-document-open"><a href="#dom-document-open">document.open()</a></code> had been called.
+    In yet more cases, the method is simply ignored, or throws an
+    exception. To make matters worse, the exact behavior of this
+    method can in some cases be dependent on network latency, which
+    can lead to failures that are very hard to debug. <strong>For all
+    these reasons, use of this method is strongly
+    discouraged.</strong></p>
     <p>This method throws an <code><a href="#invalid_state_err">INVALID_STATE_ERR</a></code> exception
     when invoked on <a href="#xml-documents">XML documents</a>.</p>
-    <p>Unless called from the body of a <code><a href="#script">script</a></code> element
-    while the document is being parsed, or called on a script-created
-    document, calling this method will clear the current page first,
-    as if <code title="dom-document-open"><a href="#dom-document-open">document.open()</a></code> had
-    been called.</p>
   </dl><div class="impl">
+  <p><code><a href="#document">Document</a></code> objects have an
+  <dfn id="ignore-destructive-writes-counter">ignore-destructive-writes counter</dfn>, which is used in
+  conjunction with the processing of <code><a href="#script">script</a></code> elements to
+  prevent external scripts from being able to use <code title="dom-document-write"><a href="#dom-document-write">document.write()</a></code> to blow away the
+  document by implicitly calling <code title="dom-document-open"><a href="#dom-document-open">document.open()</a></code>. Initially, the
+  counter must be set to zero.</p>
   <p>The <dfn id="dom-document-write" title="dom-document-write"><code>document.write(...)</code></dfn>
   method must act as follows:</p>
@@ -10139,8 +10151,8 @@
     <p>If the <a href="#insertion-point">insertion point</a> is undefined and the
-    <code><a href="#document">Document</a></code> has the <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a>
-    flag set, then abort these steps.</p>
+    <code><a href="#document">Document</a></code>'s <a href="#ignore-destructive-writes-counter">ignore-destructive-writes
+    counter</a> is greater than zero, then abort these steps.</p>
@@ -12389,15 +12401,6 @@
   <a href="#parser-inserted">"parser-inserted"</a>, to let the parser know when to
   execute the script.</p>
-  <p>The fourth is a flag is the <dfn id="ignore-destructive-writes">"ignore-destructive-writes"</dfn> flag.
-  Initially, <code><a href="#script">script</a></code> elements must have this flag unset
-  (script blocks, when created, do not have a "ignore-destructive-writes"
-  flag). This flag is used to ensure that scripts <em>not</em>
-  inserted by the parser but inserted while a parser is active do not
-  blow away the document if they use the <code title="dom-document-write"><a href="#dom-document-write">document.write()</a></code> API.
-  <code><a href="#document">Document</a></code> objects can also have this flag set; it's
-  propagated to the <code><a href="#document">Document</a></code> when the script runs.</p>
   <p>The last few pieces of state are <dfn id="the-script-block-s-type"><var>the script block's
   type</var></dfn>, <dfn id="the-script-block-s-character-encoding"><var>the script block's character
   encoding</var></dfn>, and <dfn id="the-script-block-s-fallback-character-encoding"><var>the script block's fallback
@@ -12553,16 +12556,6 @@
-   <li>
-    <p>If the element's <code><a href="#document">Document</a></code> has an <a href="#active-parser">active
-    parser</a>, and the parser's <a href="#script-nesting-level">script nesting level</a>
-    is non-zero, but this <code><a href="#script">script</a></code> element does not have
-    the <a href="#parser-inserted">"parser-inserted"</a> flag set, the user agent must
-    set the element's <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a> flag.</p>
-   </li>
    <li id="script-processing-encoding">
     <p>If the <code><a href="#script">script</a></code> element has a <code title="attr-script-charset"><a href="#attr-script-charset">charset</a></code> attribute, then let
@@ -12755,6 +12748,12 @@
    <!-- SCRIPT EXEC -->
+    <p>Executing the script block must consists of running the
+    following steps. For the purposes of these steps, the script is
+    considered to be from an <i>external file</i> if, while the
+    <a href="#running-a-script">running a script</a> algorithm above was running for this
+    script, the <code><a href="#script">script</a></code> element had a <code title="attr-script-src"><a href="#attr-script-src">src</a></code> attribute specified.</p>
       <p>Initialize <dfn id="the-script-block-s-source"><var>the script block's source</var></dfn> as
@@ -12860,19 +12859,11 @@
-      <p>If the <code><a href="#script">script</a></code> element's
-      <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a> flag is set, then flag the
-      <code><a href="#document">Document</a></code> the <code><a href="#script">script</a></code> element was in
-      when the <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a> flag was set as being
-      itself <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a>. Let <var title="">neutralized doc</var> be that
+      <p>If the script is from an external file, then increment the
+      <a href="#ignore-destructive-writes-counter">ignore-destructive-writes counter</a> of the
+      <code><a href="#script">script</a></code> element's <code><a href="#document">Document</a></code>. Let <var title="">neutralized doc</var> be that
       <code><a href="#document">Document</a></code>.</p>
-      <!-- theorem: this can only happen when the parser nesting
-      levels of all parsers on this thread are zero, so any scripts
-      inserted while this is true will not themselves have the flag
-      said, so we don't have to worry about this being a counter
-      instead of just a boolean. -->
@@ -12889,8 +12880,9 @@
-      <p>Remove the <a href="#ignore-destructive-writes">"ignore-destructive-writes"</a> flag from <var title="">neutralized doc</var>, if it was set in the earlier
-      step.</p>
+      <p>Decrement the <a href="#ignore-destructive-writes-counter">ignore-destructive-writes counter</a>
+      of <var title="">neutralized doc</var>, if it was incremented in
+      the earlier step.</p>
Received on Tuesday, 12 October 2010 21:20:47 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:10:10 UTC