()
| 144 | // NOTE(smblott). This could be better, see: https://dom.spec.whatwg.org/#interface-range |
| 145 | // (however, that probably wouldn't work for inputs). |
| 146 | getDirection() { |
| 147 | // Try to move the selection forward or backward, check whether it got bigger or smaller (then |
| 148 | // restore it). |
| 149 | for (const direction of [forward, backward]) { |
| 150 | const change = this.extendByOneCharacter(direction); |
| 151 | if (change) { |
| 152 | this.extendByOneCharacter(this.opposite[direction]); |
| 153 | if (change > 0) { |
| 154 | return direction; |
| 155 | } else { |
| 156 | return this.opposite[direction]; |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | return forward; |
| 161 | } |
| 162 | |
| 163 | collapseSelectionToAnchor() { |
| 164 | if (this.selection.toString().length == 0) return; |
no test coverage detected