You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bootstrap Slider v10.6.1
Jquery v3.3.1
Tested using Chrome v72
Description
If you call slider() on a jQuery object which has matched no elements, it will return undefined which will break chaining.
Steps to reproduce
Call slider() on a jQuery object which contains no elements
Examine the returned value
Expected behaviour
The return value should be an empty jQuery object, the same as if you had called $(). This would allow safe chaining with further jQuery functions such as on() regardless of whether the element has been matched or not.
Actual behaviour
The return value is undefined and calling other jQuery functions will throw an error. The original object is unchanged (i.e. what you called .slider() on is unchanged.
The text was updated successfully, but these errors were encountered:
Should note - as a workaround (as demonstrated in the fiddle) you can still safely attach events to the 'original' object without chaining them:
const $el = $('#iDontExist');
$el.slider() // returns undefined
$el.on('slide', handleSlide);
// Works fine, whether or not `#iDontExist` is present in DOM.
$('#iDontExist').slider().on('slide', handleSlide);
// Breaks if `#iDontExist` is not present in DOM as slider() will return undefined.
Upon investigation this may be an error with Bridget implementation in bootstrap-slider.
I'm not sure how you handle this dependency as it is bundled into the main src/bootstrap-slider.js file. I've created a pull request which fixes the issue: #917
Fiddle: https://jsfiddle.net/aduw6L0p/
Bootstrap Slider v10.6.1
Jquery v3.3.1
Tested using Chrome v72
Description
If you call
slider()
on a jQuery object which has matched no elements, it will returnundefined
which will break chaining.Steps to reproduce
slider()
on a jQuery object which contains no elementsExpected behaviour
The return value should be an empty jQuery object, the same as if you had called
$()
. This would allow safe chaining with further jQuery functions such ason()
regardless of whether the element has been matched or not.Actual behaviour
The return value is
undefined
and calling other jQuery functions will throw an error. The original object is unchanged (i.e. what you called.slider()
on is unchanged.The text was updated successfully, but these errors were encountered: