Skip to content

Commit 2aa0000

Browse files
zcorpandomenic
authored andcommitted
Don't serialize an extra LF in <pre>, <textarea>, <listing>
This was implemented in Presto in ~2012, and recently implemented in Gecko, but it broke CKEditor (http://dev.ckeditor.com/ticket/14814#ticket) so it is being backed out again in Gecko. Fixes whatwg#944.
1 parent 56d6645 commit 2aa0000

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

source

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57812,7 +57812,7 @@ o............A....e
5781257812
data-x="attr-script-src">src</code> content attribute, and the <span>Should element's inline
5781357813
behavior be blocked by Content Security Policy?</span> algorithm returns "<code
5781457814
data-x="">Blocked</code>" when executed upon the <code>script</code> element, "<code
57815-
data-x="">script</code>", and the <code>script</code> element's <code>child text content</code>,
57815+
data-x="">script</code>", and the <code>script</code> element's <span>child text content</span>,
5781657816
then abort these steps. The script is not executed. <ref spec="CSP"></p></li>
5781757817

5781857818
<li id="script-processing-for">
@@ -108553,11 +108553,6 @@ document.body.appendChild(text);
108553108553
<!-- also, i guess: image, but we don't list it because we don't consider it an "element",
108554108554
more a "macro", and thus we should never serialize it -->
108555108555

108556-
<p>If <var>current node</var> is a <code>pre</code>, <code>textarea</code>, or
108557-
<code>listing</code> element, and the first child node of the element, if any, is a
108558-
<code>Text</code> node whose character data has as its first character a U+000A LINE FEED
108559-
(LF) character, then append a U+000A LINE FEED (LF) character.</p>
108560-
108561108556
<p>Append the value of running the <span>HTML fragment serialization algorithm</span> on the
108562108557
<var>current node</var> element (thus recursing into this algorithm for that
108563108558
element), followed by a U+003C LESS-THAN SIGN character (&lt;), a U+002F SOLIDUS character
@@ -108638,7 +108633,7 @@ document.body.appendChild(text);
108638108633
<p class="warning">It is possible that the output of this algorithm, if parsed with an <span>HTML
108639108634
parser</span>, will not return the original tree structure. Tree structures that do not roundtrip
108640108635
a serialize and reparse step can also be produced by the <span>HTML parser</span> itself, although
108641-
such cases are non-conforming.</p>
108636+
such cases are typically non-conforming.</p>
108642108637

108643108638
<div class="example">
108644108639

@@ -108707,6 +108702,26 @@ document.body.appendChild(text);
108707108702

108708108703
</div>
108709108704

108705+
<p>For historical reasons, this algorithm does not round-trip an initial U+000A LINE FEED (LF)
108706+
character in <code>pre</code>, <code>textarea</code>, or <code>listing</code> elements, even
108707+
though (in the first two cases) the markup being round-tripped can be conforming. The <span>HTML
108708+
parser</span> will drop such a character during parsing, but this algorithm does <em>not</em>
108709+
serialize an extra U+000A LINE FEED (LF) character.</p>
108710+
<!-- https://github.com/whatwg/html/issues/944 -->
108711+
108712+
<div class="example">
108713+
<p>For example, consider the following markup:</p>
108714+
108715+
<pre>&lt;pre>
108716+
108717+
Hello.&lt;/pre></pre>
108718+
108719+
<p>When this document is first parsed, the <code>pre</code> element's <span>child text
108720+
content</span> starts with a single newline character. After a serialize-reparse roundtrip, the
108721+
<code>pre</code> element's <span>child text content</span> is simply "<code
108722+
data-x="">Hello.</code>".</p>
108723+
</div>
108724+
108710108725
<p><dfn id="escapingString">Escaping a string</dfn> (for the purposes of the algorithm above)
108711108726
consists of running the following steps:</p>
108712108727

0 commit comments

Comments
 (0)