Always pass in a blank object for arguments
This fixes an issue where preventing the default behaviour on some events would trigger an exception. This was bacause the event relay was expecting there to always be an object passed in for arguments, and this wasn't always the case. This closes https://github.com/select2/select2/issues/3431.
This commit is contained in:
parent
8722ae2c81
commit
7166935958
6 changed files with 15 additions and 15 deletions
18
src/js/select2/core.js
vendored
18
src/js/select2/core.js
vendored
|
@ -274,7 +274,7 @@ define([
|
|||
|
||||
this.on('query', function (params) {
|
||||
if (!self.isOpen()) {
|
||||
self.trigger('open');
|
||||
self.trigger('open', {});
|
||||
}
|
||||
|
||||
this.dataAdapter.query(params, function (data) {
|
||||
|
@ -304,19 +304,19 @@ define([
|
|||
|
||||
evt.preventDefault();
|
||||
} else if (key === KEYS.ENTER) {
|
||||
self.trigger('results:select');
|
||||
self.trigger('results:select', {});
|
||||
|
||||
evt.preventDefault();
|
||||
} else if ((key === KEYS.SPACE && evt.ctrlKey)) {
|
||||
self.trigger('results:toggle');
|
||||
self.trigger('results:toggle', {});
|
||||
|
||||
evt.preventDefault();
|
||||
} else if (key === KEYS.UP) {
|
||||
self.trigger('results:previous');
|
||||
self.trigger('results:previous', {});
|
||||
|
||||
evt.preventDefault();
|
||||
} else if (key === KEYS.DOWN) {
|
||||
self.trigger('results:next');
|
||||
self.trigger('results:next', {});
|
||||
|
||||
evt.preventDefault();
|
||||
}
|
||||
|
@ -339,9 +339,9 @@ define([
|
|||
this.close();
|
||||
}
|
||||
|
||||
this.trigger('disable');
|
||||
this.trigger('disable', {});
|
||||
} else {
|
||||
this.trigger('enable');
|
||||
this.trigger('enable', {});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -403,7 +403,7 @@ define([
|
|||
return;
|
||||
}
|
||||
|
||||
this.trigger('close');
|
||||
this.trigger('close', {});
|
||||
};
|
||||
|
||||
Select2.prototype.isOpen = function () {
|
||||
|
@ -421,7 +421,7 @@ define([
|
|||
}
|
||||
|
||||
this.$container.addClass('select2-container--focus');
|
||||
this.trigger('focus');
|
||||
this.trigger('focus', {});
|
||||
};
|
||||
|
||||
Select2.prototype.enable = function (args) {
|
||||
|
|
2
src/js/select2/dropdown/closeOnSelect.js
vendored
2
src/js/select2/dropdown/closeOnSelect.js
vendored
|
@ -25,7 +25,7 @@ define([
|
|||
return;
|
||||
}
|
||||
|
||||
this.trigger('close');
|
||||
this.trigger('close', {});
|
||||
};
|
||||
|
||||
return CloseOnSelect;
|
||||
|
|
4
src/js/select2/results.js
vendored
4
src/js/select2/results.js
vendored
|
@ -305,7 +305,7 @@ define([
|
|||
var data = $highlighted.data('data');
|
||||
|
||||
if ($highlighted.attr('aria-selected') == 'true') {
|
||||
self.trigger('close');
|
||||
self.trigger('close', {});
|
||||
} else {
|
||||
self.trigger('select', {
|
||||
data: data
|
||||
|
@ -427,7 +427,7 @@ define([
|
|||
data: data
|
||||
});
|
||||
} else {
|
||||
self.trigger('close');
|
||||
self.trigger('close', {});
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
2
src/js/select2/selection/allowClear.js
vendored
2
src/js/select2/selection/allowClear.js
vendored
|
@ -62,7 +62,7 @@ define([
|
|||
|
||||
this.$element.val(this.placeholder.id).trigger('change');
|
||||
|
||||
this.trigger('toggle');
|
||||
this.trigger('toggle', {});
|
||||
};
|
||||
|
||||
AllowClear.prototype._handleKeyboardClear = function (_, evt, container) {
|
||||
|
|
2
src/js/select2/selection/clickMask.js
vendored
2
src/js/select2/selection/clickMask.js
vendored
|
@ -13,7 +13,7 @@ define([
|
|||
);
|
||||
|
||||
this.$mask.on('mousedown touchstart click', function () {
|
||||
self.trigger('close');
|
||||
self.trigger('close', {});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
2
src/js/select2/selection/search.js
vendored
2
src/js/select2/selection/search.js
vendored
|
@ -184,7 +184,7 @@ define([
|
|||
data: item
|
||||
});
|
||||
|
||||
this.trigger('open');
|
||||
this.trigger('open', {});
|
||||
|
||||
this.$search.val(item.text + ' ');
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue