Ember
migration
byCodemod

Ember/5/Jquery Apis

/icons/calendar.svg

Last update

Jul 24, 2024

This codemod replaces all calls to this.$() inside of an Ember.Component with this.element property, which provides a reference to a native DOM element.

Events

Before:

import Component from '@ember/component';
export default Component.extend({
waitForAnimation() {
this.$().on('transitionend', () => this.doSomething());
},
});

After:

import Component from '@ember/component';
export default Component.extend({
waitForAnimation() {
this.element.addEventListener('transitionend', () =>
this.doSomething(),
);
},
});

Query Selector

Before:

import Component from '@ember/component';
export default Component.extend({
waitForAnimation() {
this.$('.animated').on('transitionend', () => this.doSomething());
},
});

After:

import Component from '@ember/component';
export default Component.extend({
waitForAnimation() {
this.element
.querySelectorAll('.animated')
.forEach((el) =>
el.addEventListener('transitionend', () => this.doSomething()),
);
},
});

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now