This commit is contained in:
Daiana Cambruzzi Ávila 2021-12-19 10:51:31 -05:00 committed by GitHub
commit 9e8448a846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 24 deletions

View file

@ -1,4 +1,4 @@
/*! choices.js v9.0.1 | © 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */ /*! choices.js v9.0.1 | © 2020 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
(function webpackUniversalModuleDefinition(root, factory) { (function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object') if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(); module.exports = factory();
@ -2571,16 +2571,15 @@ function () {
}; };
Choices.prototype._addEventListeners = function () { Choices.prototype._addEventListeners = function () {
var documentElement = document.documentElement; // capture events - can cancel event processing or propagation // capture events - can cancel event processing or propagation
this.containerOuter.element.addEventListener('touchend', this._onTouchEnd, true);
documentElement.addEventListener('touchend', this._onTouchEnd, true);
this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true); this.containerOuter.element.addEventListener('keydown', this._onKeyDown, true);
this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation` this.containerOuter.element.addEventListener('mousedown', this._onMouseDown, true); // passive events - doesn't call `preventDefault` or `stopPropagation`
documentElement.addEventListener('click', this._onClick, { this.containerOuter.element.addEventListener('click', this._onClick, {
passive: true passive: true
}); });
documentElement.addEventListener('touchmove', this._onTouchMove, { this.containerOuter.element.addEventListener('touchmove', this._onTouchMove, {
passive: true passive: true
}); });
this.dropdown.element.addEventListener('mouseover', this._onMouseOver, { this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {
@ -2616,12 +2615,11 @@ function () {
}; };
Choices.prototype._removeEventListeners = function () { Choices.prototype._removeEventListeners = function () {
var documentElement = document.documentElement; this.containerOuter.element.removeEventListener('touchend', this._onTouchEnd, true);
documentElement.removeEventListener('touchend', this._onTouchEnd, true);
this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true); this.containerOuter.element.removeEventListener('keydown', this._onKeyDown, true);
this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true); this.containerOuter.element.removeEventListener('mousedown', this._onMouseDown, true);
documentElement.removeEventListener('click', this._onClick); this.containerOuter.element.removeEventListener('click', this._onClick);
documentElement.removeEventListener('touchmove', this._onTouchMove); this.containerOuter.element.removeEventListener('touchmove', this._onTouchMove);
this.dropdown.element.removeEventListener('mouseover', this._onMouseOver); this.dropdown.element.removeEventListener('mouseover', this._onMouseOver);
if (this._isSelectOneElement) { if (this._isSelectOneElement) {
@ -3577,7 +3575,7 @@ function () {
}; };
Choices.prototype._generatePlaceholderValue = function () { Choices.prototype._generatePlaceholderValue = function () {
if (this._isSelectElement) { if (this._isSelectElement && this.passedElement.placeholderOption) {
var placeholderOption = this.passedElement.placeholderOption; var placeholderOption = this.passedElement.placeholderOption;
return placeholderOption ? placeholderOption.text : null; return placeholderOption ? placeholderOption.text : null;
} }

File diff suppressed because one or more lines are too long

View file

@ -1334,10 +1334,12 @@ class Choices implements Choices {
} }
_addEventListeners(): void { _addEventListeners(): void {
const { documentElement } = document;
// capture events - can cancel event processing or propagation // capture events - can cancel event processing or propagation
documentElement.addEventListener('touchend', this._onTouchEnd, true); this.containerOuter.element.addEventListener(
'touchend',
this._onTouchEnd,
true,
);
this.containerOuter.element.addEventListener( this.containerOuter.element.addEventListener(
'keydown', 'keydown',
this._onKeyDown, this._onKeyDown,
@ -1350,10 +1352,16 @@ class Choices implements Choices {
); );
// passive events - doesn't call `preventDefault` or `stopPropagation` // passive events - doesn't call `preventDefault` or `stopPropagation`
documentElement.addEventListener('click', this._onClick, { passive: true }); this.containerOuter.element.addEventListener('click', this._onClick, {
documentElement.addEventListener('touchmove', this._onTouchMove, {
passive: true, passive: true,
}); });
this.containerOuter.element.addEventListener(
'touchmove',
this._onTouchMove,
{
passive: true,
},
);
this.dropdown.element.addEventListener('mouseover', this._onMouseOver, { this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {
passive: true, passive: true,
}); });
@ -1388,9 +1396,11 @@ class Choices implements Choices {
} }
_removeEventListeners(): void { _removeEventListeners(): void {
const { documentElement } = document; this.containerOuter.element.removeEventListener(
'touchend',
documentElement.removeEventListener('touchend', this._onTouchEnd, true); this._onTouchEnd,
true,
);
this.containerOuter.element.removeEventListener( this.containerOuter.element.removeEventListener(
'keydown', 'keydown',
this._onKeyDown, this._onKeyDown,
@ -1402,8 +1412,11 @@ class Choices implements Choices {
true, true,
); );
documentElement.removeEventListener('click', this._onClick); this.containerOuter.element.removeEventListener('click', this._onClick);
documentElement.removeEventListener('touchmove', this._onTouchMove); this.containerOuter.element.removeEventListener(
'touchmove',
this._onTouchMove,
);
this.dropdown.element.removeEventListener('mouseover', this._onMouseOver); this.dropdown.element.removeEventListener('mouseover', this._onMouseOver);
if (this._isSelectOneElement) { if (this._isSelectOneElement) {