From 0ee47acab91e42d074b4ec0b073f5aed7c410962 Mon Sep 17 00:00:00 2001 From: Alexander Boychenko Date: Tue, 8 May 2018 15:39:52 +0700 Subject: [PATCH 1/2] Fixes `disabled` autoClose for dropdown if it wasn't disabled before --- src/dropdown/aubs-dropdown.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dropdown/aubs-dropdown.js b/src/dropdown/aubs-dropdown.js index 9b82fa2..e8c75ac 100644 --- a/src/dropdown/aubs-dropdown.js +++ b/src/dropdown/aubs-dropdown.js @@ -40,20 +40,22 @@ export class AubsDropdownCustomAttribute { } } - detached() { - if (this.autoClose !== 'disabled') { + removeListener(autoClose) { + if (autoClose !== 'disabled') { document.removeEventListener('click', this.outsideClickListener); } } + detached() { + this.removeListener(this.autoClose); + } + autoCloseChanged(newValue, oldValue){ if(!this.isAttached){ return; } - if(oldValue !== 'disabled'){ - this.detached(); - } + this.removeListener(oldValue); this.setListener(); } From e0589558db2c3d1f41598742ee17f2302288d42c Mon Sep 17 00:00:00 2001 From: Alexander Boychenko Date: Thu, 10 May 2018 16:36:04 +0700 Subject: [PATCH 2/2] Fixes `disabled` autoClose for dropdown if it wasn't disabled before. built --- dist/amd/dropdown/aubs-dropdown.js | 12 +++++++----- dist/commonjs/dropdown/aubs-dropdown.js | 12 +++++++----- dist/es2015/dropdown/aubs-dropdown.js | 12 +++++++----- dist/system/dropdown/aubs-dropdown.js | 12 +++++++----- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/dist/amd/dropdown/aubs-dropdown.js b/dist/amd/dropdown/aubs-dropdown.js index a0baa5d..25b3f7f 100644 --- a/dist/amd/dropdown/aubs-dropdown.js +++ b/dist/amd/dropdown/aubs-dropdown.js @@ -99,20 +99,22 @@ define(["exports", "aurelia-framework", "../utils/bootstrap-options"], function } }; - AubsDropdownCustomAttribute.prototype.detached = function detached() { - if (this.autoClose !== 'disabled') { + AubsDropdownCustomAttribute.prototype.removeListener = function removeListener(autoClose) { + if (autoClose !== 'disabled') { document.removeEventListener('click', this.outsideClickListener); } }; + AubsDropdownCustomAttribute.prototype.detached = function detached() { + this.removeListener(this.autoClose); + }; + AubsDropdownCustomAttribute.prototype.autoCloseChanged = function autoCloseChanged(newValue, oldValue) { if (!this.isAttached) { return; } - if (oldValue !== 'disabled') { - this.detached(); - } + this.removeListener(oldValue); this.setListener(); }; diff --git a/dist/commonjs/dropdown/aubs-dropdown.js b/dist/commonjs/dropdown/aubs-dropdown.js index 2cec2f5..8227903 100644 --- a/dist/commonjs/dropdown/aubs-dropdown.js +++ b/dist/commonjs/dropdown/aubs-dropdown.js @@ -98,20 +98,22 @@ var AubsDropdownCustomAttribute = exports.AubsDropdownCustomAttribute = (_dec = } }; - AubsDropdownCustomAttribute.prototype.detached = function detached() { - if (this.autoClose !== 'disabled') { + AubsDropdownCustomAttribute.prototype.removeListener = function removeListener(autoClose) { + if (autoClose !== 'disabled') { document.removeEventListener('click', this.outsideClickListener); } }; + AubsDropdownCustomAttribute.prototype.detached = function detached() { + this.removeListener(this.autoClose); + }; + AubsDropdownCustomAttribute.prototype.autoCloseChanged = function autoCloseChanged(newValue, oldValue) { if (!this.isAttached) { return; } - if (oldValue !== 'disabled') { - this.detached(); - } + this.removeListener(oldValue); this.setListener(); }; diff --git a/dist/es2015/dropdown/aubs-dropdown.js b/dist/es2015/dropdown/aubs-dropdown.js index 0826036..e433ef8 100644 --- a/dist/es2015/dropdown/aubs-dropdown.js +++ b/dist/es2015/dropdown/aubs-dropdown.js @@ -83,20 +83,22 @@ export let AubsDropdownCustomAttribute = (_dec = inject(Element), _dec2 = bindab } } - detached() { - if (this.autoClose !== 'disabled') { + removeListener(autoClose) { + if (autoClose !== 'disabled') { document.removeEventListener('click', this.outsideClickListener); } } + detached() { + this.removeListener(this.autoClose); + } + autoCloseChanged(newValue, oldValue) { if (!this.isAttached) { return; } - if (oldValue !== 'disabled') { - this.detached(); - } + this.removeListener(oldValue); this.setListener(); } diff --git a/dist/system/dropdown/aubs-dropdown.js b/dist/system/dropdown/aubs-dropdown.js index b27ea46..ea46bc1 100644 --- a/dist/system/dropdown/aubs-dropdown.js +++ b/dist/system/dropdown/aubs-dropdown.js @@ -105,20 +105,22 @@ System.register(["aurelia-framework", "../utils/bootstrap-options"], function (_ } }; - AubsDropdownCustomAttribute.prototype.detached = function detached() { - if (this.autoClose !== 'disabled') { + AubsDropdownCustomAttribute.prototype.removeListener = function removeListener(autoClose) { + if (autoClose !== 'disabled') { document.removeEventListener('click', this.outsideClickListener); } }; + AubsDropdownCustomAttribute.prototype.detached = function detached() { + this.removeListener(this.autoClose); + }; + AubsDropdownCustomAttribute.prototype.autoCloseChanged = function autoCloseChanged(newValue, oldValue) { if (!this.isAttached) { return; } - if (oldValue !== 'disabled') { - this.detached(); - } + this.removeListener(oldValue); this.setListener(); };