1- import Component from '@ember /component' ;
1+ import Component from '@glimmer /component' ;
22import { 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+ }
0 commit comments