aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/textcontrol.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/textcontrol.rs')
-rw-r--r--components/script/dom/textcontrol.rs11
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