Skip to content

Commit ac52e65

Browse files
authored
Remove processing for document.open()'s type parameter
Chrome, Edge, and Safari don't implement it and this is considered a legacy method. Follow-ups: whatwg#3564 and whatwg#3565. Tests: web-platform-tests/wpt#9978. Fixes whatwg#3546.
1 parent 9a2a66c commit ac52e65

File tree

1 file changed

+14
-62
lines changed

1 file changed

+14
-62
lines changed

source

Lines changed: 14 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -9174,7 +9174,7 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {
91749174
readonly attribute <span>HTMLOrSVGScriptElement</span>? <span data-x="dom-document-currentScript">currentScript</span>; // classic scripts in a document tree only
91759175

91769176
// <span>dynamic markup insertion</span>
9177-
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type = "text/html", optional DOMString replace = "");
9177+
[<span>CEReactions</span>] <span>Document</span> <span data-x="dom-document-open">open</span>(optional DOMString type, optional DOMString replace = ""); // type is ignored
91789178
<span>WindowProxy</span> <span data-x="dom-document-open">open</span>(USVString url, DOMString name, DOMString features);
91799179
[<span>CEReactions</span>] void <span data-x="dom-document-close">close</span>();
91809180
[<span>CEReactions</span>] void <span data-x="dom-document-write">write</span>(DOMString... text);
@@ -90577,19 +90577,14 @@ document.body.appendChild(frame)</pre>
9057790577
with different numbers of arguments.</p>
9057890578

9057990579
<dl class="domintro">
90580-
9058190580
<dt><var>document</var> = <var>document</var> . <code subdfn data-x="dom-document-open">open</code>( [ <var>type</var> [, <var>replace</var> ] ] )</dt>
90582-
9058390581
<dd>
90584-
9058590582
<p>Causes the <code>Document</code> to be replaced in-place, as if it was a new
9058690583
<code>Document</code> object, but reusing the previous object, which is then returned.</p>
9058790584

90588-
<p>If the <var>type</var> argument is omitted or has the value
90589-
"<code>text/html</code>", then the resulting <code>Document</code> has an HTML parser associated
90590-
with it, which can be given data to parse using <code
90591-
data-x="dom-document-write">document.write()</code>. Otherwise, all content passed to <code
90592-
data-x="dom-document-write">document.write()</code> will be parsed as plain text.</p>
90585+
<p>The resulting <code>Document</code> has an HTML parser associated with it, which can be given
90586+
data to parse using <code data-x="dom-document-write">document.write()</code>. (The
90587+
<var>type</var> argument is ignored.)</p>
9059390588

9059490589
<p>If the <var>replace</var> argument is present and has the value "<code
9059590590
data-x="">replace</code>", the existing entries in the session history for the
@@ -90602,17 +90597,10 @@ document.body.appendChild(frame)</pre>
9060290597

9060390598
<p>Throws an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code> if the
9060490599
parser is currently executing a <span>custom element constructor</span>.</p>
90605-
9060690600
</dd>
9060790601

9060890602
<dt><var>window</var> = <var>document</var> . <code data-x="dom-document-open">open</code>( <var>url</var>, <var>name</var>, <var>features</var> )</dt>
90609-
90610-
<dd>
90611-
90612-
<p>Works like the <code data-x="dom-open">window.open()</code> method.</p>
90613-
90614-
</dd>
90615-
90603+
<dd><p>Works like the <code data-x="dom-open">window.open()</code> method.</p></dd>
9061690604
</dl>
9061790605

9061890606
<div w-nodev>
@@ -90623,8 +90611,8 @@ document.body.appendChild(frame)</pre>
9062390611
unloaded</span>. Initially, the counter must be set to zero.</p> <!--
9062490612
https://www.hixie.ch/tests/adhoc/dom/level0/document/open/unload/ -->
9062590613

90626-
<p>The <dfn>document open steps</dfn>, given a <var>document</var>, <var>type</var>, and
90627-
<var>replaceInput</var>, are as follows:</p>
90614+
<p>The <dfn>document open steps</dfn>, given a <var>document</var> and <var>replaceInput</var>,
90615+
are as follows:</p>
9062890616

9062990617
<ol>
9063090618
<li><p>If <var>document</var> is an <span data-x="XML documents">XML document</span>, then throw
@@ -90770,41 +90758,6 @@ document.body.appendChild(frame)</pre>
9077090758
<li><p>Set the <span>current document readiness</span> of <var>document</var> to "<code
9077190759
data-x="">loading</code>".</p></li>
9077290760

90773-
<li>
90774-
90775-
<!-- text/plain handling -->
90776-
90777-
<p>If <var>type</var> is an <span>ASCII case-insensitive</span> match for the string
90778-
"<code data-x="">replace</code>", then, for historical reasons, set it to the string "<code
90779-
data-x="">text/html</code>".</p>
90780-
90781-
<p>Otherwise:</p>
90782-
90783-
<p>If the <var>type</var> string contains a U+003B SEMICOLON character (;), remove the
90784-
first such character and all characters from it up to the end of the string.</p>
90785-
90786-
<p><span>Strip leading and trailing ASCII whitespace</span> from <var>type</var>.</p>
90787-
90788-
</li>
90789-
90790-
<li>
90791-
90792-
<p>If <var>type</var> is <em>not</em> now an <span>ASCII case-insensitive</span> match
90793-
for the string "<code>text/html</code>", then act as if the tokenizer had emitted a start tag
90794-
token with the tag name "pre" followed by a single U+000A LINE FEED (LF) character<!-- to get
90795-
eaten, so that a leading LF in the written text doesn't get eaten itself-->, then switch the
90796-
<span>HTML parser</span>'s tokenizer to the <span>PLAINTEXT state</span>.</p>
90797-
90798-
<!--
90799-
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20%0D%0A%20%20var%20d%20%3D%20document.getElementsByTagName('iframe')%5B0%5D.contentDocument%3B%0D%0A%20%20d.open('image%2Fsvg%2Bxml')%3B%0D%0A%20%20d.write(%22%3Cinput%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%20value%3D'(x)html'%2F%3E%22)%3B%0D%0A%20%20d.close()%3B%0D%0A%7D%3B%3C%2Fscript%3E
90800-
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20%7B%20%0D%0A%20%20var%20d%20%3D%20document.getElementsByTagName('iframe')%5B0%5D.contentDocument%3B%0D%0A%20%20d.open('image%2Fgif')%3B%0D%0A%20%20var%20a%20%3D%20%5B%200x47%2C%200x49%2C%200x46%2C%200x38%2C%200x39%2C%200x61%2C%200x01%2C%200x00%2C%200x01%2C%200x00%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x80%2C%200xff%2C%200x00%2C%200xc0%2C%200xc0%2C%200xc0%2C%200x00%2C%200x00%2C%200x00%2C%200x21%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200xf9%2C%200x04%2C%200x01%2C%200x00%2C%200x00%2C%200x00%2C%200x00%2C%200x2c%2C%200x00%2C%200x00%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x00%2C%200x00%2C%200x01%2C%200x00%2C%200x01%2C%200x00%2C%200x00%2C%200x02%2C%200x02%2C%200x44%2C%0D%0A%20%20%20%20%20%20%20%20%20%20%20%200x01%2C%200x00%2C%200x3b%20%5D%3B%0D%0A%20%20var%20s%20%3D%20%22%22%3B%0D%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20a.length%3B%20i%20%2B%3D%201)%0D%0A%20%20%20%20s%20%2B%3D%20String.fromCharCode(a%5Bi%5D)%3B%0D%0A%20%20d.write(s)%3B%0D%0A%20%20d.close()%3B%0D%0A%7D%3B%3C%2Fscript%3E
90801-
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27Text%2Fplain%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E
90802-
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27%20text%2Fplain%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E
90803-
https://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E...%3Ciframe%3E%3C%2Fiframe%3E%3Cscript%3Eonload%20%3D%20function%20()%20{%20%0A%20%20var%20d%20%3D%20document.getElementsByTagName(%27iframe%27)[0].contentDocument%3B%0A%20%20d.open(%27text%2Fplain%3B%27)%3B%0A%20%20d.write(%27%3Cb%3Etest%27)%3B%0A%20%20d.close()%3B%0A}%3B%3C%2Fscript%3E
90804-
-->
90805-
90806-
</li>
90807-
9080890761
<li><p>Remove any <span data-x="concept-task">tasks</span> queued by the <span>history traversal
9080990762
task source</span> that are associated with any <code>Document</code> objects in the
9081090763
<span>top-level browsing context</span>'s <span>document family</span>.</p></li>
@@ -90841,10 +90794,11 @@ document.body.appendChild(frame)</pre>
9084190794
<p>When invoked with two arguments or fewer, the <code
9084290795
data-x="dom-document-open">document.open(<var>type</var>, <var>replace</var>)</code> method must
9084390796
return the result of running the <span>document open steps</span> with this <code>Document</code>
90844-
object, <var>type</var>, and <var>replace</var>.
90797+
object and <var>replace</var>.
9084590798

90846-
<p class="note">The <code data-x="dom-document-open">document.open()</code> method does not affect
90847-
whether a <code>Document</code> is <span>ready for post-load tasks</span> or <span>completely
90799+
<p class="note">The <var>type</var> argument is ignored. Also, the <code
90800+
data-x="dom-document-open">document.open()</code> method does not affect whether a
90801+
<code>Document</code> is <span>ready for post-load tasks</span> or <span>completely
9084890802
loaded</span>.</p>
9084990803

9085090804
<p>When invoked with three arguments, the <code data-x="dom-document-open">open(<var>url</var>,
@@ -90989,12 +90943,10 @@ document.body.appendChild(frame)</pre>
9098990943
0 or <var>document</var>'s <span>ignore-destructive-writes counter</span> is greater than 0,
9099090944
then return.</p></li>
9099190945

90992-
<li><p>Run the <span>document open steps</span> with <var>document</var>, "<code
90993-
data-x="">text/html</code>", and the empty string. If the user <span>refused to allow the
90994-
document to be unloaded</span>, then return. Otherwise, the <span>insertion
90995-
point</span> will point at just before the end of the (empty) <span>input
90946+
<li><p>Run the <span>document open steps</span> with <var>document</var> and the empty string.
90947+
If the user <span>refused to allow the document to be unloaded</span>, then return. Otherwise,
90948+
the <span>insertion point</span> will point at just before the end of the (empty) <span>input
9099690949
stream</span>.</p></li>
90997-
<!-- The second and third argument passed above are the defaults per document.open()'s IDL. -->
9099890950
</ol>
9099990951
</li>
9100090952

0 commit comments

Comments
 (0)