mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-09 17:16:36 +02:00
Merge pull request #209 from maximmig/master
Backup & recover original styles: added test
This commit is contained in:
commit
a7ee256a85
18
assets/scripts/dist/choices.js
vendored
18
assets/scripts/dist/choices.js
vendored
|
@ -351,11 +351,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
// Reinstate passed element
|
||||
this.passedElement.classList.remove(this.config.classNames.input, this.config.classNames.hiddenState);
|
||||
this.passedElement.removeAttribute('tabindex');
|
||||
// restore original styles if any
|
||||
var oldStyle = this.passedElement.getAttribute('data-choices-js-orig-style');
|
||||
if (Boolean(oldStyle)) {
|
||||
this.passedElement.removeAttribute('data-choices-js-orig-style');
|
||||
this.passedElement.setAttribute('style', oldStyle);
|
||||
// Recover original styles if any
|
||||
var origStyle = this.passedElement.getAttribute('data-choice-orig-style');
|
||||
if (Boolean(origStyle)) {
|
||||
this.passedElement.removeAttribute('data-choice-orig-style');
|
||||
this.passedElement.setAttribute('style', origStyle);
|
||||
} else {
|
||||
this.passedElement.removeAttribute('style');
|
||||
}
|
||||
|
@ -2624,10 +2624,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this.passedElement.classList.add(this.config.classNames.input, this.config.classNames.hiddenState);
|
||||
|
||||
this.passedElement.tabIndex = '-1';
|
||||
// persist original styles if any
|
||||
var oldStyle = this.passedElement.getAttribute('style');
|
||||
if (Boolean(oldStyle)) {
|
||||
this.passedElement.setAttribute('data-choices-js-orig-style', oldStyle);
|
||||
// Backup original styles if any
|
||||
var origStyle = this.passedElement.getAttribute('style');
|
||||
if (Boolean(origStyle)) {
|
||||
this.passedElement.setAttribute('data-choice-orig-style', origStyle);
|
||||
}
|
||||
this.passedElement.setAttribute('style', 'display:none;');
|
||||
this.passedElement.setAttribute('aria-hidden', 'true');
|
||||
|
|
2
assets/scripts/dist/choices.js.map
vendored
2
assets/scripts/dist/choices.js.map
vendored
File diff suppressed because one or more lines are too long
4
assets/scripts/dist/choices.min.js
vendored
4
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -281,11 +281,11 @@ class Choices {
|
|||
// Reinstate passed element
|
||||
this.passedElement.classList.remove(this.config.classNames.input, this.config.classNames.hiddenState);
|
||||
this.passedElement.removeAttribute('tabindex');
|
||||
// restore original styles if any
|
||||
const oldStyle = this.passedElement.getAttribute('data-choices-js-orig-style');
|
||||
if (Boolean(oldStyle)) {
|
||||
this.passedElement.removeAttribute('data-choices-js-orig-style');
|
||||
this.passedElement.setAttribute('style', oldStyle);
|
||||
// Recover original styles if any
|
||||
const origStyle = this.passedElement.getAttribute('data-choice-orig-style');
|
||||
if (Boolean(origStyle)) {
|
||||
this.passedElement.removeAttribute('data-choice-orig-style');
|
||||
this.passedElement.setAttribute('style', origStyle);
|
||||
} else {
|
||||
this.passedElement.removeAttribute('style');
|
||||
}
|
||||
|
@ -2584,10 +2584,10 @@ class Choices {
|
|||
);
|
||||
|
||||
this.passedElement.tabIndex = '-1';
|
||||
// persist original styles if any
|
||||
const oldStyle = this.passedElement.getAttribute('style');
|
||||
if (Boolean(oldStyle)) {
|
||||
this.passedElement.setAttribute('data-choices-js-orig-style', oldStyle);
|
||||
// Backup original styles if any
|
||||
const origStyle = this.passedElement.getAttribute('style');
|
||||
if (Boolean(origStyle)) {
|
||||
this.passedElement.setAttribute('data-choice-orig-style', origStyle);
|
||||
}
|
||||
this.passedElement.setAttribute('style', 'display:none;');
|
||||
this.passedElement.setAttribute('aria-hidden', 'true');
|
||||
|
|
|
@ -28,7 +28,7 @@ describe('Choices', () => {
|
|||
expect(this.choices).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have initalised', function() {
|
||||
it('should have initialised', function() {
|
||||
expect(this.choices.initialised).toBe(true);
|
||||
});
|
||||
|
||||
|
@ -135,6 +135,24 @@ describe('Choices', () => {
|
|||
it('should create a dropdown', function() {
|
||||
expect(this.choices.dropdown).toEqual(jasmine.any(HTMLElement));
|
||||
});
|
||||
|
||||
it('should backup and recover original styles', function () {
|
||||
const origStyle = 'background-color: #ccc; margin: 5px padding: 10px;';
|
||||
|
||||
this.choices.destroy();
|
||||
this.input.setAttribute('style', origStyle);
|
||||
this.choices = new Choices(this.input);
|
||||
|
||||
let style = this.input.getAttribute('data-choice-orig-style');
|
||||
expect(style).toEqual(origStyle);
|
||||
|
||||
this.choices.destroy();
|
||||
style = this.input.getAttribute('data-choice-orig-style');
|
||||
expect(style).toBeNull();
|
||||
|
||||
style = this.input.getAttribute('style');
|
||||
expect(style).toEqual(origStyle);
|
||||
});
|
||||
});
|
||||
|
||||
describe('should accept text inputs', function() {
|
||||
|
|
Loading…
Reference in a new issue