Bug 156285

Summary: Newlines lost in .innerHTML serialization of <pre> when first character is a newline
Product: WebKit Reporter: Simon Pieters (:zcorpan) <zcorpan>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WONTFIX    
Severity: Normal CC: cdumez
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Simon Pieters (:zcorpan) 2016-04-06 03:43:52 PDT
The HTML spec says

> If current node is a pre, textarea, or listing element, and the first child node of the element, if any, is a Text node whose character data has as its first character a U+000A LINE FEED (LF) character, then append a U+000A LINE FEED (LF) character.

https://html.spec.whatwg.org/#html-fragment-serialisation-algorithm

This is because otherwise it doesn't round-trip correctly if the data starts with a LF.

See https://github.com/whatwg/html/issues/944
Comment 1 Simon Pieters (:zcorpan) 2016-09-23 07:08:35 PDT
https://github.com/whatwg/html/pull/1815