From 7af24a05fe1e3dca6d9c94c5699680bc622573e5 Mon Sep 17 00:00:00 2001 From: Scott Kidder Date: Wed, 29 Aug 2018 15:08:44 -0400 Subject: [PATCH] support closure action because sendAction is deprecated --- addon/components/range-slider.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addon/components/range-slider.js b/addon/components/range-slider.js index 40c6e6f..b43cfd4 100644 --- a/addon/components/range-slider.js +++ b/addon/components/range-slider.js @@ -87,11 +87,20 @@ export default Component.extend({ this.slider = slider; sliderEvents.forEach(event => { - if (!isEmpty(this.get(`on-${event}`))) { + const eventActionName = `on-${event}`; + + if (!isEmpty(this.get(eventActionName))) { slider.on(event, () => { run(this, function() { - let val = this.get("slider").get(); - this.sendAction(`on-${event}`, val); + const val = this.get('slider').get(); + const action = this.get(eventActionName); + + if (typeof(action) === 'string') { + // Note that `sendAction` is deprecated and this will trigger a deprecation message. + this.sendAction(eventActionName, val); + } else if (typeof(action) === 'function') { + action(val); + } }); }); }