mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement normalization for textarea "API value"
This commit is contained in:
parent
a7a5babb3a
commit
95a7e09b40
2 changed files with 5 additions and 10 deletions
|
@ -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)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue