* @getSelection: Gets the selection bounds of a focused textarea, input or * contentEditable node. * -@input: Look up selection bounds of this input * -@return {start: selectionStart, end: selectionEnd}
(input)
| 10721 | */ |
| 10722 | |
| 10723 | function getSelection(input) { |
| 10724 | var selection; |
| 10725 | |
| 10726 | if ('selectionStart' in input) { |
| 10727 | // Modern browser with input or textarea. |
| 10728 | selection = { |
| 10729 | start: input.selectionStart, |
| 10730 | end: input.selectionEnd |
| 10731 | }; |
| 10732 | } else { |
| 10733 | // Content editable or old IE textarea. |
| 10734 | selection = getOffsets(input); |
| 10735 | } |
| 10736 | |
| 10737 | return selection || { |
| 10738 | start: 0, |
| 10739 | end: 0 |
| 10740 | }; |
| 10741 | } |
| 10742 | /** |
| 10743 | * @setSelection: Sets the selection bounds of a textarea or input and focuses |
| 10744 | * the input. |
no test coverage detected