Skip to content

Commit de7ecef

Browse files
zuzusikValentinH
authored andcommitted
fix(options): react to changes of options of Function type (#590)
fixes #589
1 parent a1e69b0 commit de7ecef

File tree

7 files changed

+37
-14
lines changed

7 files changed

+37
-14
lines changed

dist/rzslider.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! angularjs-slider - v6.4.0 -
22
(c) Rafal Zajac <[email protected]>, Valentin Hervieu <[email protected]>, Jussi Saarivirta <[email protected]>, Angelin Sirbu <[email protected]> -
33
https://github.com/angular-slider/angularjs-slider -
4-
2017-10-25 */
4+
2017-11-14 */
55
/*jslint unparam: true */
66
/*global angular: false, console: false, define, module */
77
;(function(root, factory) {
@@ -404,16 +404,15 @@
404404

405405
// Watchers (order is important because in case of simultaneous change,
406406
// watchers will be called in the same order)
407-
this.scope.$watch(
407+
this.scope.$watchCollection(
408408
'rzSliderOptions()',
409409
function(newValue, oldValue) {
410410
if (newValue === oldValue) return
411411
self.applyOptions() // need to be called before synchronizing the values
412412
self.syncLowValue()
413413
if (self.range) self.syncHighValue()
414414
self.resetSlider()
415-
},
416-
true
415+
}
417416
)
418417

419418
this.scope.$watch('rzSliderModel', function(newValue, oldValue) {

dist/rzslider.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rzslider.scss

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/rzslider.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,16 +408,15 @@
408408

409409
// Watchers (order is important because in case of simultaneous change,
410410
// watchers will be called in the same order)
411-
this.scope.$watch(
411+
this.scope.$watchCollection(
412412
'rzSliderOptions()',
413413
function(newValue, oldValue) {
414414
if (newValue === oldValue) return
415415
self.applyOptions() // need to be called before synchronizing the values
416416
self.syncLowValue()
417417
if (self.range) self.syncHighValue()
418418
self.resetSlider()
419-
},
420-
true
419+
}
421420
)
422421

423422
this.scope.$watch('rzSliderModel', function(newValue, oldValue) {

tests/specs/options-handling-test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,5 +1678,30 @@
16781678
expect(helper.slider.maxValue).to.equal(1000)
16791679
})
16801680
})
1681+
1682+
describe('reacting to changes - ', function() {
1683+
beforeEach(function() {
1684+
var sliderConf = {
1685+
value: 10,
1686+
options: {
1687+
floor: 0,
1688+
ceil: 100,
1689+
step: 10,
1690+
translate: function(val) {
1691+
return val + '%'
1692+
}
1693+
}
1694+
}
1695+
helper.createSlider(sliderConf)
1696+
})
1697+
1698+
it('should react to changes of options which are functions', function() {
1699+
helper.scope.slider.options.translate = function(val) {
1700+
return val + '$'
1701+
}
1702+
helper.scope.$digest()
1703+
expect(helper.slider.customTrFn(100)).to.equal('100$')
1704+
})
1705+
})
16811706
})
16821707
})()

0 commit comments

Comments
 (0)