Skip to content

Commit

Permalink
rename local function to avoid global collision
Browse files Browse the repository at this point in the history
  • Loading branch information
risadams committed Nov 4, 2022
1 parent e3a86d4 commit 7fa346f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions test/support/syn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7fa346f

Please sign in to comment.