Skip to content

Commit 51ac068

Browse files
committed
Use -in-element to render at appropriate time
1 parent e23fd04 commit 51ac068

8 files changed

Lines changed: 237 additions & 32 deletions

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<meta name="ember-cli-head-start">{{head-content}}<meta name="ember-cli-head-end">
1+
{{#-in-element headElement}}
2+
<meta name="ember-cli-head-start">{{head-content}}<meta name="ember-cli-head-end">
3+
{{/-in-element}}

app/components/head-layout.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,9 @@ import layout from 'ember-cli-head/templates/components/head-layout';
33

44
export default Ember.Component.extend({
55
tagName: '',
6+
headElement: Ember.computed(function() {
7+
let documentService = Ember.getOwner(this).lookup('service:-document');
8+
return documentService.head;
9+
}),
610
layout
711
});

app/instance-initializers/head-browser.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import ENV from '../config/environment';
22

3-
export function initialize(owner) {
3+
export function initialize() {
44
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }
55

66
// clear fast booted head (if any)
@@ -15,9 +15,6 @@ export function initialize(owner) {
1515
document.head.removeChild(startMeta);
1616
document.head.removeChild(endMeta);
1717
}
18-
19-
const component = owner.lookup('component:head-layout');
20-
component.appendTo(document.head);
2118
}
2219

2320
export default {

fastboot/instance-initializers/head-fastboot.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"ember-cli-app-version": "^1.0.0",
2727
"ember-cli-dependency-checker": "^1.3.0",
2828
"ember-cli-eslint": "^3.0.0",
29+
"ember-cli-fastboot": "^1.0.2",
2930
"ember-cli-htmlbars": "^1.1.1",
3031
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
3132
"ember-cli-inject-live-reload": "^1.4.1",
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{head-layout}}
2+
13
<h2 id="title">Welcome to Ember</h2>
24

35
{{outlet}}

tests/integration/components/head-layout-test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ moduleForComponent('head-layout', 'Integration | Component | head layout', {
66
});
77

88
test('it renders', function(assert) {
9+
let fragment = document.createDocumentFragment();
10+
this.set('stuff', fragment);
11+
this.render(hbs`{{head-layout headElement=stuff}}`);
912

10-
this.render(hbs`{{head-layout}}`);
11-
12-
assert.equal(this.$('meta[name="ember-cli-head-start"]').length, 1);
13-
assert.equal(this.$('meta[name="ember-cli-head-end"]').length, 1);
13+
assert.equal(fragment.querySelectorAll('meta[name="ember-cli-head-start"]').length, 1);
14+
assert.equal(fragment.querySelectorAll('meta[name="ember-cli-head-end"]').length, 1);
1415

1516
});

0 commit comments

Comments
 (0)