Skip to content

Commit aa1afac

Browse files
committed
Clean up few things
1 parent ce0c08a commit aa1afac

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

addon/helpers/page-title.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ export default Helper.extend({
3030
_hash._deprecate
3131
);
3232
}
33-
let hash = assign({}, _hash);
34-
hash.id = this.tokenId;
35-
hash.title = params.join('');
33+
let hash = assign(
34+
{},
35+
_hash,
36+
{
37+
id: this.tokenId,
38+
title: params.join('')
39+
}
40+
);
3641

3742
this.tokens.push(hash);
3843
this.tokens.scheduleTitleUpdate();

addon/services/page-title-list.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export default Service.extend({
2020
init() {
2121
this._super();
2222
set(this, 'tokens', A());
23-
set(this, 'length', 0);
2423
this._removeExistingTitleTag();
2524

2625
let config = getOwner(this).resolveRegistration('config:environment');
@@ -117,7 +116,6 @@ export default Service.extend({
117116
let tokens = copy(this.tokens);
118117
tokens.push(token);
119118
set(this, 'tokens', A(tokens));
120-
set(this, 'length', this.length + 1);
121119
},
122120

123121
remove(id) {
@@ -136,7 +134,6 @@ export default Service.extend({
136134
let tokens = A(copy(this.tokens));
137135
tokens.removeObject(token);
138136
set(this, 'tokens', A(tokens));
139-
set(this, 'length', this.length - 1);
140137
},
141138

142139
visibleTokens: computed('tokens', {
@@ -195,10 +192,6 @@ export default Service.extend({
195192
}
196193
}),
197194

198-
// TODO use something else for initial render for routes
199-
// without model() returning promise
200-
// Example: A -> B -> C - when C is the target route and model() takes long time to load
201-
// title of A and B will no be rendered until activeTransition.promise resolves.
202195
scheduleTitleUpdate() {
203196
let router = getOwner(this).lookup('router:main');
204197
let routes = router._routerMicrolib || router.router;

tests/unit/services/page-title-list-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module('service:page-title-list', function(hooks) {
55
setupTest(hooks);
66

77
test('the list has no tokens by default', function (assert) {
8-
assert.equal(this.owner.lookup('service:page-title-list').length, 0);
8+
assert.equal(this.owner.lookup('service:page-title-list').tokens.length, 0);
99
});
1010

1111
test('calling `push` adds a token to the end of the list', function (assert) {
1212
let list = this.owner.lookup('service:page-title-list');
1313
list.push({ id: 1});
14-
assert.equal(list.length, 1);
14+
assert.equal(list.tokens.length, 1);
1515
});
1616

1717
test('tokens have next and previous tokens', function (assert) {
@@ -24,7 +24,7 @@ module('service:page-title-list', function(hooks) {
2424
list.push(second);
2525
list.push(third);
2626

27-
assert.equal(list.length, 3);
27+
assert.equal(list.tokens.length, 3);
2828

2929
assert.equal(first.previous, null);
3030
assert.equal(first.next, second);
@@ -46,7 +46,7 @@ module('service:page-title-list', function(hooks) {
4646
list.push(second);
4747
list.push(third);
4848
list.remove(2);
49-
assert.equal(list.length, 2);
49+
assert.equal(list.tokens.length, 2);
5050

5151
assert.equal(first.previous, null);
5252
assert.equal(first.next, third);

0 commit comments

Comments
 (0)