Skip to content

Commit 4440b33

Browse files
authored
Merge pull request #1418 from Turbo87/es5-getters
Use ES5 getters instead of `.get()`
2 parents b59618f + 4827aa8 commit 4440b33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+126
-126
lines changed

app/components/api-token-row.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default Component.extend({
1515
actions: {
1616
async saveToken() {
1717
try {
18-
await this.get('api_token').save();
18+
await this.api_token.save();
1919
this.set('serverError', null);
2020
} catch(err) {
2121
let msg;
@@ -30,7 +30,7 @@ export default Component.extend({
3030

3131
async revokeToken() {
3232
try {
33-
await this.get('api_token').destroyRecord();
33+
await this.api_token.destroyRecord();
3434
} catch(err) {
3535
let msg;
3636
if (err.errors && err.errors[0] && err.errors[0].detail) {

app/components/badge-appveyor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ export default Component.extend({
1111

1212
imageUrl: computed('badge.attributes.id', function() {
1313
let id = this.get('badge.attributes.id');
14-
let branch = this.get('branch');
14+
let branch = this.branch;
1515
if (id !== undefined && id !== null) {
1616
return `https://ci.appveyor.com/api/projects/status/${id}/branch/${branch}?svg=true`;
1717
} else {
18-
let service = this.get('service');
19-
let repository = this.get('repository');
18+
let service = this.service;
19+
let repository = this.repository;
2020

2121
return `https://ci.appveyor.com/api/projects/status/${service}/${repository}?svg=true&branch=${branch}`;
2222
}
@@ -36,6 +36,6 @@ export default Component.extend({
3636
}),
3737

3838
text: computed('badge', function() {
39-
return `Appveyor build status for the ${ this.get('branch') } branch`;
39+
return `Appveyor build status for the ${ this.branch } branch`;
4040
})
4141
});

app/components/badge-circle-ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default Component.extend({
1010
return encodeURIComponent(this.get('badge.attributes.branch') || 'master');
1111
}),
1212
text: computed('branch', function() {
13-
return `Circle CI build status for the ${ this.get('branch') } branch`;
13+
return `Circle CI build status for the ${ this.branch } branch`;
1414
})
1515
});

app/components/badge-codecov.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export default Component.extend({
1313
return this.get('badge.attributes.service') || 'github';
1414
}),
1515
text: computed('branch', function() {
16-
return `CodeCov coverage status for the ${ this.get('branch') } branch`;
16+
return `CodeCov coverage status for the ${ this.branch } branch`;
1717
})
1818
});

app/components/badge-coveralls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export default Component.extend({
1313
return this.get('badge.attributes.service') || 'github';
1414
}),
1515
text: computed('branch', function() {
16-
return `Coveralls coverage status for the ${ this.get('branch') } branch`;
16+
return `Coveralls coverage status for the ${ this.branch } branch`;
1717
})
1818
});

app/components/badge-gitlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default Component.extend({
1010
return this.get('badge.attributes.branch') || 'master';
1111
}),
1212
text: computed('badge', function() {
13-
return `GitLab build status for the ${ this.get('branch') } branch`;
13+
return `GitLab build status for the ${ this.branch } branch`;
1414
})
1515
});

app/components/badge-travis-ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ export default Component.extend({
1010
return this.get('badge.attributes.branch') || 'master';
1111
}),
1212
text: computed('branch', function() {
13-
return `Travis CI build status for the ${ this.get('branch') } branch`;
13+
return `Travis CI build status for the ${ this.branch } branch`;
1414
})
1515
});

app/components/download-graph.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default Component.extend({
3131
didRender() {
3232
this._super(...arguments);
3333

34-
let data = this.get('data');
34+
let data = this.data;
3535

3636
let subarray_length = (data[1] || []).length;
3737

@@ -146,7 +146,7 @@ export default Component.extend({
146146
});
147147
view.setColumns(columns);
148148

149-
let chart = new window.google.visualization.ComboChart(this.get('element'));
149+
let chart = new window.google.visualization.ComboChart(this.element);
150150
chart.draw(view, {
151151
chartArea: { 'left': 85, 'width': '77%', 'height': '80%' },
152152
hAxis: {

app/components/email-input.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default Component.extend({
2828
emailError: '',
2929
disableResend: false,
3030
resendButtonText: computed('disableResend', 'user.email_verification_sent', function() {
31-
if (this.get('disableResend')) {
31+
if (this.disableResend) {
3232
return 'Sent!';
3333
} else if (this.get('user.email_verification_sent')) {
3434
return 'Resend';
@@ -39,19 +39,19 @@ export default Component.extend({
3939

4040
actions: {
4141
editEmail() {
42-
let email = this.get('value');
42+
let email = this.value;
4343
let isEmailNull = function(email) {
4444
return (email == null);
4545
};
4646

4747
this.set('emailIsNull', isEmailNull(email));
4848
this.set('isEditing', true);
49-
this.set('prevEmail', this.get('value'));
49+
this.set('prevEmail', this.value);
5050
},
5151

5252
saveEmail() {
53-
let userEmail = this.get('value');
54-
let user = this.get('user');
53+
let userEmail = this.value;
54+
let user = this.user;
5555

5656
let emailIsProperFormat = function(userEmail) {
5757
let regExp = /^\S+@\S+\.\S+$/;
@@ -89,11 +89,11 @@ export default Component.extend({
8989

9090
cancelEdit() {
9191
this.set('isEditing', false);
92-
this.set('value', this.get('prevEmail'));
92+
this.set('value', this.prevEmail);
9393
},
9494

9595
async resendEmail() {
96-
let user = this.get('user');
96+
let user = this.user;
9797

9898
try {
9999
await ajax(`/api/v1/users/${user.id}/resend`, { method: 'PUT' });

app/components/rl-dropdown-toggle.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export default Component.extend({
1111
attributeBindings: ['type', 'role', 'disabled'],
1212

1313
type: computed('tagName', function() {
14-
return this.get('tagName') === 'button' ? 'button' : null;
14+
return this.tagName === 'button' ? 'button' : null;
1515
}),
1616

1717
role: computed('tagName', function() {
18-
return this.get('tagName') === 'a' ? 'button' : null;
18+
return this.tagName === 'a' ? 'button' : null;
1919
}),
2020

2121
dropdownContainer: computed(function() {
@@ -29,10 +29,10 @@ export default Component.extend({
2929
disabled: false,
3030

3131
click(event) {
32-
if (!this.get('disabled')) {
33-
let propagateClicks = this.get('propagateClicks');
32+
if (!this.disabled) {
33+
let propagateClicks = this.propagateClicks;
3434

35-
this.get('dropdownContainer').send(this.get('action'));
35+
this.dropdownContainer.send(this.action);
3636

3737
if (propagateClicks === false || propagateClicks === 'false') {
3838
event.stopPropagation();

app/components/rl-dropdown.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export default Component.extend({
2020
propagateClicks: true,
2121

2222
click(event) {
23-
let closeOnChildClick = this.get('closeOnChildClick');
24-
let propagateClicks = this.get('propagateClicks');
23+
let closeOnChildClick = this.closeOnChildClick;
24+
let propagateClicks = this.propagateClicks;
2525
let $target = $(event.target);
2626
let $c = this.$();
2727

app/components/user-avatar.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export default Component.extend({
99
tagName: 'img',
1010

1111
width: computed('size', function() {
12-
if (this.get('size') === 'small') {
12+
if (this.size === 'small') {
1313
return 22;
14-
} else if (this.get('size') === 'medium-small') {
14+
} else if (this.size === 'medium-small') {
1515
return 32;
1616
} else {
1717
return 85; // medium
@@ -25,6 +25,6 @@ export default Component.extend({
2525
}),
2626

2727
src: computed('size', 'user', function() {
28-
return `${this.get('user.avatar')}&s=${this.get('width') * 2}`;
28+
return `${this.get('user.avatar')}&s=${this.width * 2}`;
2929
})
3030
});

app/components/validated-input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default Component.extend({
2525

2626
init() {
2727
this._super(...arguments);
28-
let valuePath = this.get('valuePath');
28+
let valuePath = this.valuePath;
2929

3030
defineProperty(this, 'validation', readOnly(`model.validations.attrs.${valuePath}`));
3131
defineProperty(this, 'value', alias(`model.${valuePath}`));

app/controllers/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default Controller.extend(EKMixin, {
2626
search() {
2727
this.transitionToRoute('search', {
2828
queryParams: {
29-
q: this.get('searchQuery'),
29+
q: this.searchQuery,
3030
page: 1
3131
}
3232
});

app/controllers/categories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export default Controller.extend(PaginationMixin, {
1313
totalItems: readOnly('model.meta.total'),
1414

1515
currentSortBy: computed('sort', function() {
16-
return (this.get('sort') === 'crates') ? '# Crates' : 'Alphabetical';
16+
return (this.sort === 'crates') ? '# Crates' : 'Alphabetical';
1717
}),
1818
});

app/controllers/category/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export default Controller.extend(PaginationMixin, {
1515
category: null,
1616

1717
currentSortBy: computed('sort', function() {
18-
if (this.get('sort') === 'downloads') {
18+
if (this.sort === 'downloads') {
1919
return 'All-Time Downloads';
20-
} else if (this.get('sort') === 'alpha') {
20+
} else if (this.sort === 'alpha') {
2121
return 'Alphabetical';
2222
} else {
2323
return 'Recent Downloads';

app/controllers/crate/owners.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ export default Controller.extend({
1212
this.set('error', false);
1313
this.set('invited', false);
1414

15-
const username = this.get('username');
15+
const username = this.username;
1616

1717
if (!username) {
1818
this.set('error', 'Please enter a username');
1919
return false;
2020
}
2121

2222
try {
23-
await this.get('crate').inviteOwner(username);
23+
await this.crate.inviteOwner(username);
2424
this.set('invited', `An invite has been sent to ${username}`);
2525

2626
} catch(error) {
@@ -36,7 +36,7 @@ export default Controller.extend({
3636
this.set('removed', false);
3737

3838
try {
39-
await this.get('crate').removeOwner(user.get('login'));
39+
await this.crate.removeOwner(user.get('login'));
4040
this.set('removed', `User ${user.get('login')} removed as crate owner`);
4141

4242
this.get('crate.owner_user').removeObject(user);

app/controllers/crate/version.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default Controller.extend({
1818
isDownloading: false,
1919

2020
downloadsContext: computed('requestedVersion', 'model', 'crate', function() {
21-
return this.get('requestedVersion') ? this.get('model') : this.get('crate');
21+
return this.requestedVersion ? this.model : this.crate;
2222
}),
2323
downloads: alias('downloadsContext.version_downloads'),
2424
extraDownloads: alias('downloads.content.meta.extra_downloads'),
@@ -37,7 +37,7 @@ export default Controller.extend({
3737
sortedVersions: readOnly('crate.versions'),
3838

3939
smallSortedVersions: computed('sortedVersions', function() {
40-
return this.get('sortedVersions').slice(0, NUM_VERSIONS);
40+
return this.sortedVersions.slice(0, NUM_VERSIONS);
4141
}),
4242

4343
hasMoreVersions: gt('sortedVersions.length', NUM_VERSIONS),
@@ -87,12 +87,12 @@ export default Controller.extend({
8787
}),
8888

8989
downloadData: computed('downloads', 'extraDownloads', 'requestedVersion', function() {
90-
let downloads = this.get('downloads');
90+
let downloads = this.downloads;
9191
if (!downloads) {
9292
return;
9393
}
9494

95-
let extra = this.get('extraDownloads') || [];
95+
let extra = this.extraDownloads || [];
9696

9797
let dates = {};
9898
let versions = [];
@@ -117,10 +117,10 @@ export default Controller.extend({
117117
dates[key].cnt[null] = prev + d.downloads;
118118
}
119119
});
120-
if (this.get('requestedVersion')) {
121-
versions.push(this.get('model').getProperties('id', 'num'));
120+
if (this.requestedVersion) {
121+
versions.push(this.model.getProperties('id', 'num'));
122122
} else {
123-
this.get('smallSortedVersions').forEach(version => {
123+
this.smallSortedVersions.forEach(version => {
124124
versions.push(version.getProperties('id', 'num'));
125125
});
126126
}
@@ -171,7 +171,7 @@ export default Controller.extend({
171171
toggleFollow() {
172172
this.set('fetchingFollowing', true);
173173

174-
let crate = this.get('crate');
174+
let crate = this.crate;
175175
let op = this.toggleProperty('following') ?
176176
crate.follow() : crate.unfollow();
177177

app/controllers/crates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export default Controller.extend(PaginationMixin, {
1515
totalItems: readOnly('model.meta.total'),
1616

1717
currentSortBy: computed('sort', function() {
18-
if (this.get('sort') === 'downloads') {
18+
if (this.sort === 'downloads') {
1919
return 'All-Time Downloads';
20-
} else if (this.get('sort') === 'recent-downloads') {
20+
} else if (this.sort === 'recent-downloads') {
2121
return 'Recent Downloads';
2222
} else {
2323
return 'Alphabetical';

app/controllers/dashboard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ export default Controller.extend({
1818
},
1919

2020
visibleCrates: computed('myCrates.[]', function() {
21-
return this.get('myCrates').slice(0, TO_SHOW);
21+
return this.myCrates.slice(0, TO_SHOW);
2222
}),
2323

2424
visibleFollowing: computed('myFollowing.[]', function() {
25-
return this.get('myFollowing').slice(0, TO_SHOW);
25+
return this.myFollowing.slice(0, TO_SHOW);
2626
}),
2727

2828
visibleStats: computed('myStats', function() {
29-
return this.get('myStats');
29+
return this.myStats;
3030
}),
3131

3232
hasMoreCrates: computed('myCrates.[]', function() {
@@ -40,13 +40,13 @@ export default Controller.extend({
4040
actions: {
4141
async loadMore() {
4242
this.set('loadingMore', true);
43-
let page = (this.get('myFeed').length / 10) + 1;
43+
let page = (this.myFeed.length / 10) + 1;
4444

4545
try {
4646
let data = await ajax(`/api/v1/me/updates?page=${page}`);
4747
let versions = data.versions.map(version => this.store.push(this.store.normalize('version', version)));
4848

49-
this.get('myFeed').pushObjects(versions);
49+
this.myFeed.pushObjects(versions);
5050
this.set('hasMore', data.meta.more);
5151

5252
} finally {

app/controllers/keyword/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ export default Controller.extend(PaginationMixin, {
1313
totalItems: readOnly('model.meta.total'),
1414

1515
currentSortBy: computed('sort', function() {
16-
if (this.get('sort') === 'downloads') {
16+
if (this.sort === 'downloads') {
1717
return 'All-Time Downloads';
18-
} else if (this.get('sort') === 'alpha') {
18+
} else if (this.sort === 'alpha') {
1919
return 'Alphabetical';
2020
} else {
2121
return 'Recent Downloads';

app/controllers/keywords.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ export default Controller.extend(PaginationMixin, {
1313
totalItems: readOnly('model.meta.total'),
1414

1515
currentSortBy: computed('sort', function() {
16-
return (this.get('sort') === 'crates') ? '# Crates' : 'Alphabetical';
16+
return (this.sort === 'crates') ? '# Crates' : 'Alphabetical';
1717
}),
1818
});

0 commit comments

Comments
 (0)