Skip to content
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

Enable usage in Ember 2.9 beta and above. #11

Merged
merged 1 commit into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app-lt-2-9/instance-initializers/browser/head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Ember from 'ember';
import ENV from '../../config/environment';

export function initialize(instance) {
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }

// 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(document.head);
}

export default {
name: 'head-browser',
initialize: initialize
};
19 changes: 19 additions & 0 deletions app-lt-2-9/instance-initializers/fastboot/head.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export function initialize(instance) {
const renderer = instance.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
};
Empty file removed app/.gitkeep
Empty file.
7 changes: 3 additions & 4 deletions app/instance-initializers/browser/head.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Ember from 'ember';
import ENV from '../../config/environment';

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

// 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');

const component = owner.lookup('component:head-layout');
component.appendTo(document.head);
}

Expand Down
18 changes: 5 additions & 13 deletions app/instance-initializers/fastboot/head.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
export function initialize(instance) {
const renderer = instance.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 function initialize(owner) {
const document = owner.lookup('service:-document');
const component = owner.lookup('component:head-layout');

component.appendTo(document.head);
}

export default {
Expand Down
16 changes: 15 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
/* jshint node: true */
'use strict';

var path = require('path');
var filterInitializers = require('fastboot-filter-initializers');
var VersionChecker = require('ember-cli-version-checker');
var mergeTrees = require('broccoli-merge-trees');

module.exports = {
name: 'ember-cli-head',

treeForApp: function(tree) {
treeForApp: function(defaultTree) {
var checker = new VersionChecker(this);
var emberVersion = checker.for('ember', 'bower');

var trees = [defaultTree];

if (emberVersion.lt('2.9.0-alpha.4')) {
trees.push(this.treeGenerator(path.resolve(this.root, 'app-lt-2-9')));
}

var tree = mergeTrees(trees, { overwrite: true });

return filterInitializers(tree);
}
};
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
"ember-addon"
],
"dependencies": {
"broccoli-merge-trees": "^1.1.4",
"ember-cli-babel": "^5.1.5",
"ember-cli-htmlbars": "^1.0.1",
"fastboot-filter-initializers": "0.0.1",
"ember-cli-babel": "^5.1.5"
"ember-cli-version-checker": "^1.1.6",
"fastboot-filter-initializers": "0.0.1"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down