Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.

Commit 837ebf2

Browse files
committed
Use arrow functions to set 'this' context for a function.
With arrow functions it it not necessary to use sth. like 'var self = this' because 'this' is automatically set to the surrounding scope of the function.
1 parent eb81217 commit 837ebf2

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

addon/components/datepicker-support.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default Ember.Mixin.create({
1111
endDate: undefined,
1212

1313
setupBootstrapDatepicker: Ember.on('didInsertElement', function() {
14-
var self = this;
1514

1615
this.$().
1716
datepicker({
@@ -43,27 +42,27 @@ export default Ember.Mixin.create({
4342
weekStart: this.get('weekStart'),
4443
datesDisabled: this.get('datesDisabled')
4544
}).
46-
on('changeDate', function(event) {
47-
Ember.run(function() {
48-
self._didChangeDate(event);
45+
on('changeDate', event => {
46+
Ember.run(() => {
47+
this._didChangeDate(event);
4948
});
5049
}).
51-
on('focusout', function(event) {
52-
self.sendAction('focus-out', self, event);
50+
on('focusout', event => {
51+
this.sendAction('focus-out', this, event);
5352
}).
54-
on('focusin', function(event) {
55-
self.sendAction('focus-in', self, event);
53+
on('focusin', event => {
54+
this.sendAction('focus-in', this, event);
5655
}).
57-
on('clearDate', function(event) {
58-
Ember.run(function() {
59-
self._didChangeDate(event);
56+
on('clearDate', event => {
57+
Ember.run(() => {
58+
this._didChangeDate(event);
6059
});
6160
}).
62-
on('show', function() {
63-
self.sendAction('show');
61+
on('show', () => {
62+
this.sendAction('show');
6463
}).
65-
on('hide', function() {
66-
self.sendAction('hide');
64+
on('hide', () => {
65+
this.sendAction('hide');
6766
});
6867

6968
this._updateDatepicker();
@@ -133,8 +132,7 @@ export default Ember.Mixin.create({
133132
}),
134133

135134
_updateDatepicker: function() {
136-
var self = this,
137-
element = this.$(),
135+
var element = this.$(),
138136
value = this.get('value'),
139137
dates = [];
140138

@@ -153,8 +151,8 @@ export default Ember.Mixin.create({
153151
default:
154152
dates = [null];
155153
}
156-
dates = dates.map(function(date) {
157-
return (Ember.isNone(date)) ? null : self._getDateCloneWithNoTime(date);
154+
dates = dates.map(date => {
155+
return (Ember.isNone(date)) ? null : this._getDateCloneWithNoTime(date);
158156
});
159157

160158
element.datepicker

0 commit comments

Comments
 (0)