diff options
author | Jon Leighton <j@jonathanleighton.com> | 2017-11-25 09:49:37 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2017-11-25 16:36:01 +0100 |
commit | 9b06cb33690457e86c7f1724db0c609d13bc01a4 (patch) | |
tree | 9aa3a3d06952a4eaac6cb50ef15e5ab82eb84b18 /components/script/dom/textcontrol.rs | |
parent | 95a7e09b406fe7d0a89f3352941cb36f1e44d4f6 (diff) | |
download | servo-9b06cb33690457e86c7f1724db0c609d13bc01a4.tar.gz servo-9b06cb33690457e86c7f1724db0c609d13bc01a4.zip |
Handle setting selectionStart to be > selectionEnd
Diffstat (limited to 'components/script/dom/textcontrol.rs')
-rw-r--r-- | components/script/dom/textcontrol.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs index 0b8870b1996..2b47fcd00a4 100644 --- a/components/script/dom/textcontrol.rs +++ b/components/script/dom/textcontrol.rs @@ -21,7 +21,16 @@ pub trait TextControl: DerivedFrom<EventTarget> + DerivedFrom<Node> { // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart fn set_dom_selection_start(&self, start: u32) { - self.set_selection_range(start, self.dom_selection_end(), self.selection_direction()); + // Step 2 + let mut end = self.dom_selection_end(); + + // Step 3 + if end < start { + end = start; + } + + // Step 4 + self.set_selection_range(start, end, self.selection_direction()); } // https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionend |