diff --git a/src/selectize.js b/src/selectize.js index 398371743..3dffaca45 100644 --- a/src/selectize.js +++ b/src/selectize.js @@ -2093,7 +2093,7 @@ $.extend(Selectize.prototype, { var self = this; direction = (e && e.keyCode === KEY_BACKSPACE) ? -1 : 1; - selection = getSelection(self.$control_input[0]); + selection = getInputSelection(self.$control_input[0]); if (self.$activeOption && !self.settings.hideSelected) { if (typeof self.settings.deselectBehavior === 'string' && self.settings.deselectBehavior === 'top') { @@ -2172,7 +2172,7 @@ $.extend(Selectize.prototype, { if (self.rtl) direction *= -1; tail = direction > 0 ? 'last' : 'first'; - selection = getSelection(self.$control_input[0]); + selection = getInputSelection(self.$control_input[0]); if (self.isFocused && !self.isInputHidden) { valueLength = self.$control_input.val().length; diff --git a/src/utils.js b/src/utils.js index 89d18302d..357c0d596 100644 --- a/src/utils.js +++ b/src/utils.js @@ -187,10 +187,10 @@ var watchChildEvent = function ($parent, event, selector, fn) { * @param {object} input * @returns {object} */ -var getSelection = function (input) { +var getInputSelection = function (input) { var result = {}; if (input === undefined) { - console.warn('WARN getSelection cannot locate input control'); + console.warn('WARN getInputSelection cannot locate input control'); return result; } if ('selectionStart' in input) { @@ -302,7 +302,7 @@ var autoGrow = function ($input) { ); if (keyCode === KEY_DELETE || keyCode === KEY_BACKSPACE) { - selection = getSelection($input[0]); + selection = getInputSelection($input[0]); if (selection.length) { value = value.substring(0, selection.start) + value.substring(selection.start + selection.length); } else if (keyCode === KEY_BACKSPACE && selection.start) { diff --git a/test/support/syn.js b/test/support/syn.js index 0053e3f06..12b4ff345 100644 --- a/test/support/syn.js +++ b/test/support/syn.js @@ -1548,7 +1548,7 @@ define('syn/key', [ 'syn/typeable', 'syn/browsers' ], function (syn) { - var h = syn.helpers, getSelection = function (el) { + var h = syn.helpers, getInputSelection = function (el) { var real, r, start; if (el.selectionStart !== undefined) { if (document.activeElement && document.activeElement !== el && el.selectionStart === el.selectionEnd && el.selectionStart === 0) { @@ -1752,7 +1752,7 @@ define('syn/key', [ }, getText: function (el) { if (syn.typeable.test(el)) { - var sel = getSelection(el); + var sel = getInputSelection(el); return el.value.substring(sel.start, sel.end); } var win = syn.helpers.getWindow(el); @@ -2120,7 +2120,7 @@ define('syn/key', [ syn.trigger(element, 'keyup', options.replace('-up', '')); return callback(true, element); } - var activeElement = h.getWindow(element).document.activeElement, caret = syn.typeable.test(element) && getSelection(element), key = convert[options] || options, runDefaults = syn.trigger(element, 'keydown', key), getDefault = syn.key.getDefault, prevent = syn.key.browser.prevent, defaultResult, keypressOptions = syn.key.options(key, 'keypress'); + var activeElement = h.getWindow(element).document.activeElement, caret = syn.typeable.test(element) && getInputSelection(element), key = convert[options] || options, runDefaults = syn.trigger(element, 'keydown', key), getDefault = syn.key.getDefault, prevent = syn.key.browser.prevent, defaultResult, keypressOptions = syn.key.options(key, 'keypress'); if (runDefaults) { if (!keypressOptions) { defaultResult = getDefault(key).call(element, keypressOptions, h.getWindow(element), key, undefined, caret);