diff options
author | Jon Leighton <j@jonathanleighton.com> | 2017-11-24 17:00:25 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2017-11-25 16:36:00 +0100 |
commit | 95a7e09b406fe7d0a89f3352941cb36f1e44d4f6 (patch) | |
tree | e75d2481fd326f6a900d309446df91452009f150 /components/script/textinput.rs | |
parent | a7a5babb3aa8c51218f5c0567923ab78aefbbaec (diff) | |
download | servo-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.rs | 6 |
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) }; |