Implement normalization for textarea "API value"

This commit is contained in:
Jon Leighton 2017-11-24 17:00:25 +01:00
parent a7a5babb3a
commit 95a7e09b40
2 changed files with 5 additions and 10 deletions

View file

@ -770,7 +770,11 @@ impl<T: ClipboardProvider> TextInput<T> {
/// any \n encountered will be stripped and force a new logical line. /// any \n encountered will be stripped and force a new logical line.
pub fn set_content(&mut self, content: DOMString) { pub fn set_content(&mut self, content: DOMString) {
self.lines = if self.multiline { 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 { } else {
vec!(content) vec!(content)
}; };

View file

@ -1,17 +1,8 @@
[value-defaultValue-textContent.html] [value-defaultValue-textContent.html]
type: testharness 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] [defaultValue and value are affected by textContent in combination with appending a DocumentFragment]
expected: FAIL expected: FAIL
[defaultValue and value reflect child text content, not textContent] [defaultValue and value reflect child text content, not textContent]
expected: FAIL expected: FAIL
[value normalizes CRLF even spread over multiple text nodes]
expected: FAIL