Deprecations Added in Ember 4.x

What follows is a list of deprecations introduced to Ember during the 4.x cycle.

For more information on deprecations in Ember, see the main deprecations page.

Deprecations Added in 4.0.0

§ Ember.assign

until: 5.0.0
id: ember-polyfills.deprecate-assign

Use of Ember.assign is deprecated. You should replace any calls to Ember.assign with Object.assign or use the object spread operator.

Before:

import { assign } from '@ember/polyfills';

var a = { first: 'Yehuda' };
var b = { last: 'Katz' };
assign(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' }

After:

var a = { first: 'Yehuda' };
var b = { last: 'Katz' };
Object.assign(a, b); // a == { first: 'Yehuda', last: 'Katz' }, b == { last: 'Katz' }

§ Reopening Classic Component Super Class

until: 5.0.0
id: ember.component.reopen

Reopening the Ember.Component super class has far-reaching consequences. For example, it may unexpectedly break addons that are not expecting the changes.

To respond to DOM events globally, consider instead using global event listeners.

Before:

import Component from '@ember/component';

Component.reopen({
  click() {
    console.log('Clicked on a classic component');
  }
});

After:

document.addEventListener('click', event => {
  if (event.target.classList.contains('my-component')) {
    console.log('Clicked on a classic component');
  }
});

Alternatively, you can create a custom subclass of Ember.Component with the behavior you want and subclass from that component in your app. That way, only those components which explicitly opted into the changes will be affected.

Before:

import Component from '@ember/component';

Component.reopen({
  attributeBindings: ['metadata:data-my-metadata'],
  metadata: ''
});

After:

// app/components/base.js
import Component from '@ember/component';

// Subclass from this in your app, instead of subclassing from Ember.Component
export default Component.extend({
  attributeBindings: ['metadata:data-my-metadata'],
  metadata: ''
});
until: 5.0.0
id: ember.link-to.disabled-when

Passing the @disabledWhen argument to is deprecated. Use the @disabled argument instead.'

until: 5.0.0
id: ember.link-to.disabled-when

Passing the @disabledWhen argument to is deprecated. Use the @disabled argument instead.'