From 95a7e09b406fe7d0a89f3352941cb36f1e44d4f6 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 24 Nov 2017 17:00:25 +0100 Subject: [PATCH] Implement normalization for textarea "API value" --- components/script/textinput.rs | 6 +++++- .../value-defaultValue-textContent.html.ini | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/script/textinput.rs b/components/script/textinput.rs index c4d8b3747b6f..310e05664536 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -770,7 +770,11 @@ impl TextInput { /// any \n encountered will be stripped and force a new logical line. pub fn set_content(&mut self, content: DOMString) { self.lines = if self.multiline { - content.split('\n').map(DOMString::from).collect() + // https://html.spec.whatwg.org/multipage/#textarea-line-break-normalisation-transformation + content.replace("\r\n", "\n") + .split(|c| c == '\n' || c == '\r') + .map(DOMString::from) + .collect() } else { vec!(content) }; diff --git a/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini b/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini index 9377d122a794..707484069311 100644 --- a/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini +++ b/tests/wpt/metadata/html/semantics/forms/the-textarea-element/value-defaultValue-textContent.html.ini @@ -1,17 +1,8 @@ [value-defaultValue-textContent.html] type: testharness - [defaultValue and value treat CRLF differently] - expected: FAIL - - [tests for the value setter] - expected: FAIL - [defaultValue and value are affected by textContent in combination with appending a DocumentFragment] expected: FAIL [defaultValue and value reflect child text content, not textContent] expected: FAIL - [value normalizes CRLF even spread over multiple text nodes] - expected: FAIL -