File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,15 @@ export default class PageTitleListService extends Service {
208
208
if ( isFastBoot ) {
209
209
this . updateFastbootTitle ( toBeTitle ) ;
210
210
} else {
211
+ /**
212
+ * When rendering app with "?fastboot=false" (http://ember-fastboot.com/docs/user-guide#disabling-fastboot)
213
+ * We will not have <title> element present in DOM.
214
+ *
215
+ * But this is fine as by HTML spec,
216
+ * one is created upon assigning "document.title" value;
217
+ *
218
+ * https://html.spec.whatwg.org/multipage/dom.html#dom-tree-accessors
219
+ */
211
220
this . document . title = toBeTitle ;
212
221
}
213
222
}
@@ -223,8 +232,8 @@ export default class PageTitleListService extends Service {
223
232
return ;
224
233
}
225
234
assert (
226
- "[ember-page-title]: Multiple or no < title> element(s) found. Check for other addons like ember-cli-head updating <title> as well." ,
227
- document . head . querySelectorAll ( 'title' ) . length == = 1
235
+ "[ember-page-title]: Multiple title elements found. Check for other addons like ember-cli-head updating <title> as well." ,
236
+ document . head . querySelectorAll ( 'title' ) . length < = 1
228
237
) ;
229
238
}
230
239
Original file line number Diff line number Diff line change @@ -86,4 +86,12 @@ module('Acceptance: title', function(hooks) {
86
86
87
87
assert . equal ( getPageTitle ( ) , '(10) Reader | My App' ) ;
88
88
} ) ;
89
+
90
+ test ( 'does not throw if no title element exist' , async function ( assert ) {
91
+ document . head . querySelectorAll ( 'title' ) . forEach ( ( titleElement ) => {
92
+ document . head . removeChild ( titleElement ) ;
93
+ } ) ;
94
+ await visit ( '/posts' ) ;
95
+ assert . equal ( getPageTitle ( ) , 'Posts | My App' ) ;
96
+ } ) ;
89
97
} ) ;
You can’t perform that action at this time.
0 commit comments