aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/textinput.rs
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2017-11-24 17:00:25 +0100
committerJon Leighton <j@jonathanleighton.com>2017-11-25 16:36:00 +0100
commit95a7e09b406fe7d0a89f3352941cb36f1e44d4f6 (patch)
treee75d2481fd326f6a900d309446df91452009f150 /components/script/textinput.rs
parenta7a5babb3aa8c51218f5c0567923ab78aefbbaec (diff)
downloadservo-95a7e09b406fe7d0a89f3352941cb36f1e44d4f6.tar.gz
servo-95a7e09b406fe7d0a89f3352941cb36f1e44d4f6.zip
Implement normalization for textarea "API value"
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r--components/script/textinput.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index c4d8b3747b6..310e0566453 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -770,7 +770,11 @@ impl<T: ClipboardProvider> TextInput<T> {
/// 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)
};