Skip to content

Commit

Permalink
Move title tag cleanup to page-title-list service (#117 from Cropster…
Browse files Browse the repository at this point in the history
…/engines)
  • Loading branch information
tim-evans authored Jan 3, 2018
2 parents 5c89467 + bffac38 commit d536b34
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
22 changes: 22 additions & 0 deletions addon/services/page-title-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default Ember.Service.extend({
this._super();
set(this, 'tokens', Ember.A());
set(this, 'length', 0);
this._removeExistingTitleTag();
},

/**
Expand Down Expand Up @@ -185,5 +186,26 @@ export default Ember.Service.extend({
}
}
return title.join('');
},

/**
* Remove any existing title tags from the head.
* @private
*/
_removeExistingTitleTag() {
if (this._isFastboot()) {
return;
}

let titles = document.getElementsByTagName('title');
for (let i = 0; i < titles.length; i++) {
let title = titles[i];
title.parentNode.removeChild(title);
}
},

_isFastboot() {
return typeof FastBoot !== 'undefined';
}

});
15 changes: 0 additions & 15 deletions app/instance-initializers/page-title-setup.js

This file was deleted.

0 comments on commit d536b34

Please sign in to comment.