Skip to content

Commit 21fb885

Browse files
committed
Fix computed-property.override deprecation.
See https://emberjs.com/deprecations/v3.x#toc_computed-property-override for more details.
1 parent 5bec342 commit 21fb885

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

addon/components/head-layout.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import Component from '@ember/component';
2-
import { get, computed } from '@ember/object';
3-
import { getOwner } from '@ember/application';
2+
import { inject as service } from '@ember/service';
43
import layout from '../templates/components/head-layout';
54

65
export default Component.extend({
76
tagName: '',
87
layout,
8+
document: service('-document'),
99

1010
/**
1111
* If true, this will tear down any existing head on init of this component.
@@ -15,15 +15,20 @@ export default Component.extend({
1515
*/
1616
shouldTearDownOnInit: true,
1717

18-
headElement: computed(function() {
19-
let documentService = getOwner(this).lookup('service:-document');
20-
return documentService.head;
21-
}),
18+
/**
19+
* The element to render into. Defaults to <head> in `init`, overridable for our own tests only.
20+
* @private
21+
*/
22+
headElement: null,
2223

2324
init() {
2425
this._super(...arguments);
2526

26-
if (get(this, 'shouldTearDownOnInit')) {
27+
if (this.get('headElement') === null) {
28+
this.set('headElement', this.get('document.head'));
29+
}
30+
31+
if (this.get('shouldTearDownOnInit')) {
2732
this._tearDownHead();
2833
}
2934
},
@@ -38,6 +43,7 @@ export default Component.extend({
3843
}
3944

4045
// clear fast booted head (if any)
46+
let document = this.get('document');
4147
let startMeta = document.querySelector('meta[name="ember-cli-head-start"]');
4248
let endMeta = document.querySelector('meta[name="ember-cli-head-end"]');
4349
if (startMeta && endMeta) {

tests/dummy/config/environment.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports = function(environment) {
1414
EXTEND_PROTOTYPES: {
1515
// Prevent Ember Data from overriding Date.parse.
1616
Date: false
17-
}
17+
},
18+
RAISE_ON_DEPRECATION: true
1819
},
1920

2021
APP: {

0 commit comments

Comments
 (0)