Persisting original styles of the passed element.

This commit is contained in:
Maxim Mig 2017-07-15 00:31:45 +03:00
parent 51a4f28b65
commit 8e8df3e455
2 changed files with 8 additions and 2 deletions

2
.gitignore vendored
View file

@ -1,6 +1,8 @@
node_modules
npm-debug.log
.DS_Store
.gitignore
.idea
.vscode
package-lock.json

View file

@ -281,7 +281,9 @@ class Choices {
// Reinstate passed element
this.passedElement.classList.remove(this.config.classNames.input, this.config.classNames.hiddenState);
this.passedElement.removeAttribute('tabindex');
this.passedElement.removeAttribute('style');
// restore original styles if any
this.passedElement.setAttribute('style', this.passedElement.getAttribute('data-choices-js-orig-style'));
this.passedElement.removeAttribute('data-choices-js-orig-style');
this.passedElement.removeAttribute('aria-hidden');
this.passedElement.removeAttribute('data-choice');
@ -1027,7 +1029,7 @@ class Choices {
/**
* Populate options via ajax callback
* @param {Function} fn Passed
* @param {Function} fn Function that actually makes an AJAX request
* @return {Object} Class instance
* @public
*/
@ -2577,6 +2579,8 @@ class Choices {
);
this.passedElement.tabIndex = '-1';
// persist original styles if any
this.passedElement.setAttribute('data-choices-js-orig-style', this.passedElement.getAttribute('style'));
this.passedElement.setAttribute('style', 'display:none;');
this.passedElement.setAttribute('aria-hidden', 'true');
this.passedElement.setAttribute('data-choice', 'active');