-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear fast boot rendered head on browser boot #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<meta name="ember-cli-head-start" />{{head-content}}<meta name="ember-cli-head-end" /> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Ember from 'ember'; | ||
import layout from 'ember-cli-head/templates/components/head-layout'; | ||
|
||
export default Ember.Component.extend({ | ||
tagName: '', | ||
layout | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Ember from 'ember'; | ||
|
||
export function initialize(instance) { | ||
// clear fast booted head (if any) | ||
Ember.$('meta[name="ember-cli-head-start"]') | ||
.nextUntil('meta[name="ember-cli-head-end"] ~') | ||
.addBack() | ||
.remove(); | ||
const container = instance.lookup ? instance : instance.container; | ||
const renderer = container.lookup('renderer:-dom'); | ||
const component = container.lookup('component:head-layout'); | ||
component.appendTo(renderer._dom.document.head); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In browser mode, can we just always specify document.head? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll give that a try. |
||
} | ||
|
||
export default { | ||
name: 'head-browser', | ||
initialize: initialize | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export function initialize(instance) { | ||
const container = instance.lookup ? instance : instance.container; | ||
const renderer = container.lookup('renderer:-dom'); | ||
const componentFactory = | ||
instance._lookupFactory('component:head-layout'); | ||
// explicitly set renderer & domhelper since we're in fastboot | ||
const component = componentFactory.create( | ||
instance.ownerInjection(), | ||
{ | ||
renderer, | ||
_domHelper: renderer._dom | ||
} | ||
); | ||
component.appendTo(renderer._dom.document.head); | ||
} | ||
|
||
export default { | ||
name: 'head-fastboot', | ||
initialize: initialize | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('head-layout', 'Integration | Component | head layout', { | ||
integration: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
|
||
this.render(hbs`{{head-layout}}`); | ||
|
||
assert.equal(this.$('meta[name="ember-cli-head-start"]').length, 1); | ||
assert.equal(this.$('meta[name="ember-cli-head-end"]').length, 1); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to remove this conditional, fastboot only supports ember 2.3.0+ so instance.lookup should always be present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. 👍