Skip to content

Commit

Permalink
Avoid crashing the playground app
Browse files Browse the repository at this point in the history
  • Loading branch information
raido committed Sep 3, 2020
1 parent d26898a commit 4746f01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
15 changes: 5 additions & 10 deletions tests/dummy/app/components/page-title-pane/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ export default Component.extend({

titleList: service(),

lastIndex: computed('titleList.{sortedTokens.length,tokens.length}', {
lastIndex: computed('titleList.{tokens.length}', {
get() {
return this.titleList.sortedTokens.length - 1;
return this.titleList.tokens.length - 1;
},
}),

actions: {
highlight(token) {
let sortedTokens = A(this.titleList.sortedTokens);
let tokens = A(this.titleList.tokens);
let wasActive = token.active;
this.titleList.tokens.setEach('active', false);
sortedTokens.setEach('active', false);

if (!wasActive) {
set(sortedTokens.findBy('id', token.id), 'active', true);
set(token, 'active', true);
}
tokens.setEach('active', false);
set(token, 'active', !wasActive);
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export default Component.extend({
classNames: ['nested-template'],
classNameBindings: ['active:active'],

active: computed('titleList.{sortedTokens,[email protected]}', 'token.id', {
active: computed('titleList.{[email protected]}', 'token.id', {
get() {
let sortedTokens = A(this.titleList.sortedTokens);
let token = sortedTokens.findBy('id', this.token.id);
let tokens = A(this.titleList.tokens);
let token = tokens.findBy('id', this.token.id);
return token && token.active;
},
}),
Expand Down

0 comments on commit 4746f01

Please sign in to comment.