Skip to content

Commit 4933bd3

Browse files
authored
Merge pull request seiyria#917 from ollycross/master
fix bridget bug with empty jquery object
2 parents ac821fa + e3c31ba commit 4933bd3

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/js/bootstrap-slider.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,10 @@ const windowIsDefined = (typeof window === "object");
185185
return $(this);
186186
});
187187

188-
if(!objects || objects.length > 1) {
189-
return objects;
190-
} else {
188+
if(objects.length === 1) {
191189
return objects[0];
192190
}
191+
return objects;
193192
}
194193
};
195194

test/specs/PublicMethodsSpec.js

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ describe("Public Method Tests", function() {
22
var testSlider;
33

44
describe("slider constructor", function() {
5+
describe("returns a jQuery object if it is called on a jQuery object with zero or more matching elements", function() {
6+
it("returns a jQuery object if it is called on with no matching elements", function() {
7+
testSlider = $();
8+
expect(testSlider.slider() instanceof jQuery).toBe(true);
9+
});
10+
it("returns a jQuery object if it is called on with one matching element", function() {
11+
testSlider = $('#testSlider1');
12+
expect(testSlider.slider() instanceof jQuery).toBe(true);
13+
});
14+
it("returns a jQuery object if it is called on with multiple matching elements", function() {
15+
testSlider = $('#testSlider1, #testSlider2');
16+
expect(testSlider.slider() instanceof jQuery).toBe(true);
17+
});
18+
});
19+
520
it("reads and sets the 'id' attribute of the slider instance that is created", function() {
621
var sliderId = "mySlider";
722

0 commit comments

Comments
 (0)