Skip to content

Commit

Permalink
Merge pull request #7 from kimroen/fix-context-for-title
Browse files Browse the repository at this point in the history
Fix context for title
  • Loading branch information
kimroen committed Mar 7, 2015
2 parents 18336fa + 5b6c6f3 commit 0342f6a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion tests/acceptance/document-title-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ test('dynamic title based on route attributes', function(assert) {
visit('/friendship-status');

andThen(function() {
assert.equal(router._title, 'We are friends - My Blog');
assert.equal(router._title, 'We are best friends',
'the context is correct for `title` and `titleToken`');
});
});
2 changes: 1 addition & 1 deletion tests/dummy/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Router.map(function() {
this.resource('posts', function() {});
this.route('about');
this.route('team');
this.route('friendship-status');
this.resource('friendship-status', function() {});
});

export default Router;
6 changes: 3 additions & 3 deletions tests/dummy/app/routes/friendship-status.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Ember from 'ember';

export default Ember.Route.extend({
status: 'friends',
degree: 'best',

titleToken: function(model) {
return 'We are ' + this.get('status');
title: function(tokens) {
return 'We are ' + this.get('degree') + ' ' + tokens[0];
}
});
9 changes: 9 additions & 0 deletions tests/dummy/app/routes/friendship-status/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Ember from 'ember';

export default Ember.Route.extend({
status: 'friends',

titleToken: function(model) {
return this.get('status');
}
});
2 changes: 1 addition & 1 deletion vendor/document-title/document-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Ember.Route.reopen({
if (title) {
var finalTitle;
if (typeof title === 'function') {
finalTitle = title(tokens);
finalTitle = title.call(this, tokens);
} else {
// Tokens aren't even considered... a string
// title just sledgehammer overwrites any children tokens.
Expand Down

0 comments on commit 0342f6a

Please sign in to comment.