Skip to content

Commit

Permalink
Workaround KevinSheedy#19
Browse files Browse the repository at this point in the history
  • Loading branch information
gabegorelick committed Mar 28, 2016
1 parent ac739dd commit 60ac0bf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion jquery.alphanum.js
Expand Up @@ -182,7 +182,14 @@
var newChar = String.fromCharCode(charCode);

// Determine if some text was selected / highlighted when the key was pressed
var selectionObject = $textbox.selection();
var selectionObject;
try {
selectionObject = $textbox.selection();
} catch (e) {
// This can happen on browsers that removed selection API from some
// elements. See https://github.com/KevinSheedy/jquery.alphanum/issues/19
selectionObject = {start: 0, end: $textbox.val().length};
}
var start = selectionObject.start;
var end = selectionObject.end;

Expand Down

0 comments on commit 60ac0bf

Please sign in to comment.