Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation for Ember.$() #17489

Merged
merged 1 commit into from Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion packages/ember/index.js
Expand Up @@ -561,7 +561,18 @@ Ember.VERSION = VERSION;

// ****@ember/-internals/views****
if (!views.jQueryDisabled) {
Ember.$ = views.jQuery;
Ember.$ = function() {
deprecate(
"Using Ember.$() has been deprecated, use `import jQuery from 'jquery';` instead",
false,
{
id: 'ember-views.curly-components.jquery-element',
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x#toc_jquery-apis',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we only going to have a single deprecation guide entry for all of the jQuery things, or a specific one for each deprecated "concept"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was planning to do that, as the (technically) different deprecations are very similar and related, and share the same explanation of why to deprecate them. My current draft is here: ember-learn/deprecation-app#255.

But if there is a reason to split them, we can do it!?

}
);
return views.jQuery.apply(this, arguments);
};
}
Ember.ViewUtils = {
isSimpleClick: views.isSimpleClick,
Expand Down
16 changes: 15 additions & 1 deletion packages/ember/tests/reexports_test.js
Expand Up @@ -52,6 +52,21 @@ moduleFor(
}
);

if (!jQueryDisabled) {
moduleFor(
'ember reexports: jQuery enabled',
class extends AbstractTestCase {
[`@test Ember.$ is exported`](assert) {
assert.ok(Ember.$, 'Ember.$ export exists');
expectDeprecation(() => {
let body = Ember.$('body').get(0);
assert.equal(body, document.body, 'Ember.$ exports working jQuery instance');
}, "Using Ember.$() has been deprecated, use `import jQuery from 'jquery';` instead");
}
}
);
}

let allExports = [
// @ember/-internals/environment
['ENV', '@ember/-internals/environment', { get: 'getENV' }],
Expand Down Expand Up @@ -170,7 +185,6 @@ let allExports = [
['Logger', '@ember/-internals/console', 'default'],

// @ember/-internals/views
!jQueryDisabled && ['$', '@ember/-internals/views', 'jQuery'],
['ViewUtils.isSimpleClick', '@ember/-internals/views', 'isSimpleClick'],
['ViewUtils.getViewElement', '@ember/-internals/views', 'getViewElement'],
['ViewUtils.getViewBounds', '@ember/-internals/views', 'getViewBounds'],
Expand Down