Skip to content

Commit a3c4569

Browse files
committed
Convert to glimmer. Tests pass.
1 parent 8bf5324 commit a3c4569

9 files changed

Lines changed: 111 additions & 36 deletions

File tree

addon/components/head-layout.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,30 @@
1-
import Component from '@ember/component';
1+
import Component from '@glimmer/component';
22
import { inject as service } from '@ember/service';
3-
import layout from '../templates/components/head-layout';
43

5-
export default Component.extend({
6-
tagName: '',
7-
layout,
8-
document: service('-document'),
4+
export default class HeadLayout extends Component {
5+
@service('-document') document
96

107
/**
118
* If true, this will tear down any existing head on init of this component.
129
* This is useful if there is a head built with fastboot - it will then be torn down when this is initialized in the browser.
1310
* If you do not want this behavior, you can set this to false.
1411
* @public
1512
*/
16-
shouldTearDownOnInit: true,
13+
shouldTearDownOnInit = true
1714

1815
/**
1916
* The element to render into. Defaults to <head> in `init`, overridable for our own tests only.
2017
* @private
2118
*/
22-
headElement: null,
19+
headElement = this.args.headElement || this.document.head
2320

24-
init() {
25-
this._super(...arguments);
21+
constructor() {
22+
super(...arguments);
2623

27-
if (this.get('headElement') === null) {
28-
this.set('headElement', this.get('document.head'));
29-
}
30-
31-
if (this.get('shouldTearDownOnInit')) {
24+
if (this.shouldTearDownOnInit) {
3225
this._tearDownHead();
3326
}
34-
},
27+
}
3528

3629
/**
3730
* Tear down any previous head, if there was one.
@@ -43,7 +36,7 @@ export default Component.extend({
4336
}
4437

4538
// clear fast booted head (if any)
46-
let document = this.get('document');
39+
let document = this.document;
4740
let startMeta = document.querySelector('meta[name="ember-cli-head-start"]');
4841
let endMeta = document.querySelector('meta[name="ember-cli-head-end"]');
4942
if (startMeta && endMeta) {
@@ -55,10 +48,10 @@ export default Component.extend({
5548
document.head.removeChild(startMeta);
5649
document.head.removeChild(endMeta);
5750
}
58-
},
51+
}
5952

6053
_isFastboot() {
6154
return typeof FastBoot !== 'undefined'
6255
}
6356

64-
});
57+
}

addon/services/head-data.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import Service from '@ember/service';
22

3-
export default Service.extend({
4-
});
3+
export default class HeadData extends Service {
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{{#in-element this.headElement insertBefore=null}}
2-
<meta name="ember-cli-head-start" content="">{{head-content}}<meta name="ember-cli-head-end" content="">
2+
<meta name="ember-cli-head-start" content=""><HeadContent/><meta name="ember-cli-head-end" content="">
33
{{/in-element}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from 'ember-cli-head/templates/components/head-layout';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
{{head-layout}}
1+
<HeadLayout/>
22
{{outlet}}

fastboot-tests/fixtures/fastboot/app/templates/head.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<!-- here. The 'model' available in this template can be populated by-->
33
<!-- setting values on the 'head-data' service. -->
44

5-
<meta property="og:title" content={{model.title}}>
5+
<meta property="og:title" content={{this.model.title}}>

package-lock.json

Lines changed: 90 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
"ember-auto-import": "^1.11.2",
4949
"ember-cli": "~3.26.1",
5050
"ember-cli-dependency-checker": "^3.2.0",
51-
"ember-cli-fastboot": "^2.2.2",
52-
"ember-cli-fastboot-testing": "^0.3.0",
51+
"ember-cli-fastboot": "^2.2.3",
52+
"ember-cli-fastboot-testing": "^0.5.0",
5353
"ember-cli-inject-live-reload": "^2.0.2",
5454
"ember-cli-sri": "^2.1.1",
5555
"ember-cli-terser": "^4.0.1",

tests/dummy/app/templates/head.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
<!-- here. The 'model' available in this template can be populated by-->
33
<!-- setting values on the 'head-data' service. -->
44

5-
<meta property="og:title" content={{model.title}}>
5+
<meta property="og:title" content={{this.model.title}}>

0 commit comments

Comments
 (0)