Skip to content

Commit 7f31be0

Browse files
authored
Merge pull request #45 from mydea/engines
Refactor instance-initializer
2 parents c4f0831 + 164452e commit 7f31be0

15 files changed

Lines changed: 1298 additions & 915 deletions

File tree

.bowerrc

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

.jscsrc

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

.travis.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,42 @@ node_js:
44
- "6"
55

66
sudo: false
7+
dist: trusty
8+
9+
addons:
10+
chrome: stable
711

812
cache:
913
yarn: true
1014

1115
env:
12-
# we recommend testing LTS's and latest stable release (bonus points to beta/canary)
13-
- EMBER_TRY_SCENARIO=ember-lts-2.12
14-
- EMBER_TRY_SCENARIO=ember-release
15-
- EMBER_TRY_SCENARIO=ember-beta
16-
- EMBER_TRY_SCENARIO=ember-canary
17-
- EMBER_TRY_SCENARIO=ember-default
18-
- EMBER_TRY_SCENARIO=fastboot
16+
global:
17+
# See https://git.io/vdao3 for details.
18+
- JOBS=1
19+
matrix:
20+
# we recommend new addons test the current and previous LTS
21+
# as well as latest stable release (bonus points to beta/canary)
22+
- EMBER_TRY_SCENARIO=ember-lts-2.12
23+
- EMBER_TRY_SCENARIO=ember-lts-2.16
24+
- EMBER_TRY_SCENARIO=ember-release
25+
- EMBER_TRY_SCENARIO=ember-beta
26+
- EMBER_TRY_SCENARIO=ember-canary
27+
- EMBER_TRY_SCENARIO=ember-default
28+
- EMBER_TRY_SCENARIO=fastboot
1929

2030
matrix:
2131
fast_finish: true
2232
allow_failures:
2333
- env: EMBER_TRY_SCENARIO=ember-canary
2434

2535
before_install:
26-
- npm config set spin false
36+
- curl -o- -L https://yarnpkg.com/install.sh | bash
2737
- export PATH=$HOME/.yarn/bin:$PATH
28-
- yarn global add phantomjs-prebuilt bower
29-
- npm --version
30-
- yarn --version
31-
- bower --version
32-
- phantomjs --version
3338

3439
install:
35-
- yarn install --no-lockfile
40+
- yarn install --no-lockfile --non-interactive
3641

3742
script:
3843
# Usually, it's ok to finish the test scenario without reverting
3944
# to the addon's original dependency state, skipping "cleanup".
40-
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup
45+
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO --skip-cleanup

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry "https://registry.yarnpkg.com"

addon/components/head-layout.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import Component from '@ember/component';
2+
import { get, computed } from '@ember/object';
3+
import { getOwner } from '@ember/application';
4+
import layout from '../templates/components/head-layout';
5+
6+
export default Component.extend({
7+
tagName: '',
8+
layout,
9+
10+
/**
11+
* If true, this will tear down any existing head on init of this component.
12+
* This is useful if there is a head built with fastboot - it will then be torn down when this is initialized in the browser.
13+
* If you do not want this behavior, you can set this to false.
14+
* @public
15+
*/
16+
shouldTearDownOnInit: true,
17+
18+
headElement: computed(function() {
19+
let documentService = getOwner(this).lookup('service:-document');
20+
return documentService.head;
21+
}),
22+
23+
init() {
24+
this._super(...arguments);
25+
26+
if (get(this, 'shouldTearDownOnInit')) {
27+
this._tearDownHead();
28+
}
29+
},
30+
31+
/**
32+
* Tear down any previous head, if there was one.
33+
* @private
34+
*/
35+
_tearDownHead() {
36+
if (this._isFastboot()) {
37+
return;
38+
}
39+
40+
// clear fast booted head (if any)
41+
let startMeta = document.querySelector('meta[name="ember-cli-head-start"]');
42+
let endMeta = document.querySelector('meta[name="ember-cli-head-end"]');
43+
if (startMeta && endMeta) {
44+
let el = startMeta.nextSibling;
45+
while (el && el !== endMeta) {
46+
document.head.removeChild(el);
47+
el = startMeta.nextSibling;
48+
}
49+
document.head.removeChild(startMeta);
50+
document.head.removeChild(endMeta);
51+
}
52+
},
53+
54+
_isFastboot() {
55+
return typeof FastBoot !== 'undefined'
56+
}
57+
58+
});

app/components/head-layout.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1 @@
1-
import Ember from 'ember';
2-
import layout from 'ember-cli-head/templates/components/head-layout';
3-
4-
export default Ember.Component.extend({
5-
tagName: '',
6-
headElement: Ember.computed(function() {
7-
let documentService = Ember.getOwner(this).lookup('service:-document');
8-
return documentService.head;
9-
}),
10-
layout
11-
});
1+
export { default } from 'ember-cli-head/components/head-layout';
Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,8 @@
1-
import ENV from '../config/environment';
2-
3-
export function initialize() {
4-
if (ENV['ember-cli-head'] && ENV['ember-cli-head']['suppressBrowserRender']) { return true; }
5-
6-
// clear fast booted head (if any)
7-
let startMeta = document.querySelector('meta[name="ember-cli-head-start"]')
8-
let endMeta = document.querySelector('meta[name="ember-cli-head-end"]')
9-
if (startMeta && endMeta) {
10-
let el = startMeta.nextSibling
11-
while(el && el !== endMeta) {
12-
document.head.removeChild(el);
13-
el = startMeta.nextSibling;
14-
}
15-
document.head.removeChild(startMeta);
16-
document.head.removeChild(endMeta);
17-
}
18-
}
19-
201
export default {
212
name: 'head-browser',
223
initialize() {
23-
if (typeof FastBoot === 'undefined') {
24-
initialize(...arguments);
25-
}
4+
// do nothing!
5+
// this functionality has been moved into addon/components/head-layout.js
6+
// This is only here in order to not break existing addons relying on this, e.g. ember-page-title.
267
}
278
};

bower.json

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

config/ember-try.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* eslint-env node */
21
module.exports = {
2+
useYarn: true,
33
scenarios: [
44
{
55
name: 'ember-lts-2.12',
@@ -9,6 +9,14 @@ module.exports = {
99
}
1010
}
1111
},
12+
{
13+
name: 'ember-lts-2.16',
14+
npm: {
15+
devDependencies: {
16+
'ember-source': '~2.16.0'
17+
}
18+
}
19+
},
1220
{
1321
name: 'ember-release',
1422
bower: {

package.json

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@
1919
"author": "",
2020
"license": "MIT",
2121
"devDependencies": {
22-
"broccoli-asset-rev": "^2.4.5",
23-
"chai": "^3.5.0",
24-
"ember-ajax": "^2.4.1",
25-
"ember-cli": "2.12.2",
26-
"ember-cli-app-version": "^1.0.0",
27-
"ember-cli-dependency-checker": "^1.3.0",
28-
"ember-cli-eslint": "^3.0.0",
29-
"ember-cli-fastboot": "^1.0.2",
30-
"ember-cli-htmlbars": "^1.1.1",
31-
"ember-cli-htmlbars-inline-precompile": "^0.4.0",
32-
"ember-cli-inject-live-reload": "^1.4.1",
33-
"ember-cli-qunit": "^3.1.0",
34-
"ember-cli-release": "0.2.8",
35-
"ember-cli-shims": "^1.0.2",
36-
"ember-cli-sri": "^2.1.0",
37-
"ember-cli-uglify": "^1.2.0",
38-
"ember-disable-prototype-extensions": "^1.1.0",
22+
"broccoli-asset-rev": "^2.6.0",
23+
"chai": "^4.1.2",
24+
"ember-ajax": "^3.0.0",
25+
"ember-cli": "^2.18.0",
26+
"ember-cli-app-version": "^3.1.3",
27+
"ember-cli-dependency-checker": "^2.1.0",
28+
"ember-cli-eslint": "^4.2.3",
29+
"ember-cli-fastboot": "^1.1.1",
30+
"ember-cli-htmlbars": "^2.0.3",
31+
"ember-cli-htmlbars-inline-precompile": "^1.0.2",
32+
"ember-cli-inject-live-reload": "^1.7.0",
33+
"ember-cli-qunit": "^4.2.1",
34+
"ember-cli-release": "^0.2.9",
35+
"ember-cli-shims": "^1.2.0",
36+
"ember-cli-sri": "^2.1.1",
37+
"ember-cli-uglify": "^2.0.0",
38+
"ember-disable-prototype-extensions": "^1.1.3",
3939
"ember-disable-proxy-controllers": "^1.0.1",
4040
"ember-export-application-global": "^1.0.5",
4141
"ember-fastboot-addon-tests": "^0.4.0",
4242
"ember-load-initializers": "^0.6.0",
43-
"ember-resolver": "^2.0.3",
44-
"ember-source": "~2.12.0",
45-
"loader.js": "^4.2.3"
43+
"ember-resolver": "^4.5.0",
44+
"ember-source": "^2.18.0",
45+
"loader.js": "^4.6.0"
4646
},
4747
"keywords": [
4848
"ember-addon"
4949
],
5050
"dependencies": {
51-
"ember-cli-babel": "^6.1.0",
52-
"ember-cli-htmlbars": "^2.0.1"
51+
"ember-cli-babel": "^6.11.0",
52+
"ember-cli-htmlbars": "^2.0.3"
5353
},
5454
"engines": {
5555
"node": ">= 4"

0 commit comments

Comments
 (0)