Refactor instance-initializer#45
Conversation
e9ee853 to
6f2178a
Compare
rwjblue
left a comment
There was a problem hiding this comment.
Looks good, I like the approach 👍 .
Thanks for working on this!
| document.head.removeChild(startMeta); | ||
| document.head.removeChild(endMeta); | ||
| } | ||
| // do nothing! |
There was a problem hiding this comment.
Can you move this comment directly down into the initialize method below, and remove this extra function?
be072ef to
fc638a9
Compare
|
I removed the extra function in the instance initializer and moved the comments down! |
| get, | ||
| computed, | ||
| getOwner | ||
| } = Ember; |
There was a problem hiding this comment.
FWIW, since this is moved to addon/** we should start migrating to the newer style imports directly.
This would become:
import Component from '@ember/component';
import { get } from '@ember/object';
import { computed } from '@ember/object';
import { getOwner } from '@ember/application';| @@ -0,0 +1,63 @@ | |||
| import Ember from 'ember'; | |||
| import layout from 'ember-cli-head/templates/components/head-layout'; | |||
There was a problem hiding this comment.
I'd generally prefer relative imports here, but I don't feel super strongly...
This would become:
import layout from '../templates/components/head-layout';Previously, any eventual head data built by fastboot was cleaned up in an instance initializer. This was now moved into the head-layout component, where this happens on init. This fixes an issue where this cleanup happens multiple times when using lazy loading engines. Additionally, this moves the head-layout component into the addon namespace, which makes it possible to overwrite/extend from it.
|
I adjusted the import paths for the head-layout component according to your suggestions :) |
|
Could we get a new release with that fix? That would be great! |
|
So sorry @mydea, I completely lost track of this! It has been released as 0.4.1... |
This PR does two main things:
Basically, in lazy loading engines, the instance initializer will run whenever another engine is entered, thus trashing the head.
This PR changes this, so that the head is trashed in the
init()hook of thehead-layoutcomponent.In addition to fixing this issue, it should also make it much easier to overwrite/adapt this behavior for special requirements.