Added the listeners added in this.containerOuter.element to allow shadow dom active.

This commit is contained in:
Daiana Cambruzzi Ávila 2020-04-15 09:07:42 -03:00
parent d2a80fcb12
commit 7ffd9bb471
3 changed files with 18 additions and 11 deletions

View file

@ -2571,16 +2571,15 @@ function () {
};
Choices.prototype._addEventListeners = function () {
var documentElement = document.documentElement; // capture events - can cancel event processing or propagation
documentElement.addEventListener('touchend', this._onTouchEnd, true);
// capture events - can cancel event processing or propagation
this.containerOuter.element.addEventListener('touchend', this._onTouchEnd, 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`
documentElement.addEventListener('click', this._onClick, {
this.containerOuter.element.addEventListener('click', this._onClick, {
passive: true
});
documentElement.addEventListener('touchmove', this._onTouchMove, {
this.containerOuter.element.addEventListener('touchmove', this._onTouchMove, {
passive: true
});
this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {

File diff suppressed because one or more lines are too long

View file

@ -1308,10 +1308,12 @@ class Choices {
}
_addEventListeners(): void {
const { documentElement } = document;
// 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(
'keydown',
this._onKeyDown,
@ -1324,10 +1326,16 @@ class Choices {
);
// passive events - doesn't call `preventDefault` or `stopPropagation`
documentElement.addEventListener('click', this._onClick, { passive: true });
documentElement.addEventListener('touchmove', this._onTouchMove, {
this.containerOuter.element.addEventListener('click', this._onClick, {
passive: true,
});
this.containerOuter.element.addEventListener(
'touchmove',
this._onTouchMove,
{
passive: true,
},
);
this.dropdown.element.addEventListener('mouseover', this._onMouseOver, {
passive: true,
});