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

[CLEANUP beta] Remove internal jQuery usage #19676

Merged
merged 1 commit into from Aug 20, 2021
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
14 changes: 0 additions & 14 deletions packages/@ember/-internals/environment/lib/env.ts
Expand Up @@ -128,20 +128,6 @@ export const ENV = {
*/
_DEBUG_RENDER_TREE: DEBUG,

/**
Whether the app is using jQuery. See RFC #294.

This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.

@property _JQUERY_INTEGRATION
@for EmberENV
@type Boolean
@default true
@private
*/
_JQUERY_INTEGRATION: true,

/**
Whether the app defaults to using async observers.

Expand Down
2 changes: 0 additions & 2 deletions packages/@ember/-internals/views/index.d.ts
Expand Up @@ -2,8 +2,6 @@ import { Option } from '@glimmer/interfaces';
import { SimpleElement } from '@simple-dom/interface';
import { Object as EmberObject } from '@ember/-internals/runtime';

export { jQuery, jQueryDisabled } from './lib/system/jquery';

export const ActionSupport: any;
export const ChildViewsSupport: any;
export const ClassNamesSupport: any;
Expand Down
1 change: 0 additions & 1 deletion packages/@ember/-internals/views/index.js
@@ -1,4 +1,3 @@
export { jQuery, jQueryDisabled } from './lib/system/jquery';
export {
addChildView,
isSimpleClick,
Expand Down
2 changes: 0 additions & 2 deletions packages/@ember/-internals/views/lib/system/jquery.d.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/@ember/-internals/views/lib/system/jquery.js

This file was deleted.

24 changes: 1 addition & 23 deletions packages/@ember/application/instance.js
Expand Up @@ -4,7 +4,6 @@

import { get, set, computed } from '@ember/-internals/metal';
import * as environment from '@ember/-internals/browser-environment';
import { jQuery } from '@ember/-internals/views';
import EngineInstance from '@ember/engine/instance';
import { renderSettled } from '@ember/-internals/glimmer';

Expand Down Expand Up @@ -57,8 +56,7 @@ const ApplicationInstance = EngineInstance.extend({

/**
The root DOM element of the Application as an element or a
[jQuery-compatible selector
string](http://api.jquery.com/category/selectors/).
CSS selector.

@private
@property {String|DOMElement} rootElement
Expand Down Expand Up @@ -328,20 +326,6 @@ ApplicationInstance.reopenClass({
*/
class BootOptions {
constructor(options = {}) {
/**
Provide a specific instance of jQuery. This is useful in conjunction with
the `document` option, as it allows you to use a copy of `jQuery` that is
appropriately bound to the foreign `document` (e.g. a jsdom).

This is highly experimental and support very incomplete at the moment.

@property jQuery
@type Object
@default auto-detected
@private
*/
this.jQuery = jQuery; // This default is overridable below

/**
Interactive mode: whether we need to set up event delegation and invoke
lifecycle callbacks on Components.
Expand Down Expand Up @@ -392,7 +376,6 @@ class BootOptions {
}

if (!this.isBrowser) {
this.jQuery = null;
this.isInteractive = false;
this.location = 'none';
}
Expand All @@ -416,7 +399,6 @@ class BootOptions {
}

if (!this.shouldRender) {
this.jQuery = null;
this.isInteractive = false;
}

Expand Down Expand Up @@ -486,10 +468,6 @@ class BootOptions {
this.location = options.location;
}

if (options.jQuery !== undefined) {
this.jQuery = options.jQuery;
}

if (options.isInteractive !== undefined) {
this.isInteractive = Boolean(options.isInteractive);
}
Expand Down
21 changes: 1 addition & 20 deletions packages/@ember/application/lib/application.js
Expand Up @@ -11,7 +11,7 @@ import { join, once, run, schedule } from '@ember/runloop';
import { libraries } from '@ember/-internals/metal';
import { _loaded, runLoadHooks } from './lazy_load';
import { RSVP } from '@ember/-internals/runtime';
import { EventDispatcher, jQuery, jQueryDisabled } from '@ember/-internals/views';
import { EventDispatcher } from '@ember/-internals/views';
import {
Route,
Router,
Expand All @@ -26,9 +26,6 @@ import Engine from '@ember/engine';
import { privatize as P } from '@ember/-internals/container';
import { setupApplicationRegistry } from '@ember/-internals/glimmer';
import { RouterService } from '@ember/-internals/routing';
import { JQUERY_INTEGRATION } from '@ember/deprecated-features';

let librariesRegistered = false;

/**
An instance of `Application` is the starting point for every Ember
Expand Down Expand Up @@ -353,12 +350,6 @@ const Application = Engine.extend({
// eslint-disable-line no-unused-vars
this._super(...arguments);

if (!this.$) {
this.$ = jQuery;
}

registerLibraries();

if (DEBUG) {
if (ENV.LOG_VERSION) {
// we only need to see this once per Application#init
Expand Down Expand Up @@ -1170,14 +1161,4 @@ function commonSetupRegistry(registry) {
registry.register('service:router', RouterService);
}

function registerLibraries() {
if (!librariesRegistered) {
librariesRegistered = true;

if (JQUERY_INTEGRATION && hasDOM && !jQueryDisabled) {
libraries.registerCoreLibrary('jQuery', jQuery().jquery);
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Slightly unrelated, but is libraries really used for anything after this removal? I don't think it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, you mean the whole libraries thing, or just the import here? The import is used here for logging the Ember and possibly other registered addon versions to the console. And for that libraries.register() is still used in addons (I am using it here for example, but this reminds me I actually have to refactor this to not use the Ember global!) and ember-data itself. So I think this has to stay!?

}
}
}

export default Application;
8 changes: 1 addition & 7 deletions packages/@ember/application/tests/application_test.js
Expand Up @@ -4,7 +4,6 @@ import { ENV } from '@ember/-internals/environment';
import { libraries } from '@ember/-internals/metal';
import { getDebugFunction, setDebugFunction } from '@ember/debug';
import { Router, NoneLocation, Route as EmberRoute } from '@ember/-internals/routing';
import { jQueryDisabled, jQuery } from '@ember/-internals/views';
import { _loaded } from '@ember/application';
import Controller from '@ember/controller';
import { Object as EmberObject } from '@ember/-internals/runtime';
Expand Down Expand Up @@ -279,12 +278,7 @@ moduleFor(
runTask(() => this.createApplication());

assert.equal(messages[1], 'Ember : ' + VERSION);
if (jQueryDisabled) {
assert.equal(messages[2], 'my-lib : ' + '2.0.0a');
} else {
assert.equal(messages[2], 'jQuery : ' + jQuery().jquery);
assert.equal(messages[3], 'my-lib : ' + '2.0.0a');
}
assert.equal(messages[2], 'my-lib : ' + '2.0.0a');

libraries.deRegister('my-lib');
}
Expand Down
1 change: 0 additions & 1 deletion packages/@ember/deprecated-features/index.ts
Expand Up @@ -4,7 +4,6 @@
// not the version that the feature will be removed.

export const ROUTER_EVENTS = !!'4.0.0';
export const JQUERY_INTEGRATION = !!'3.9.0';
export const APP_CTRL_ROUTER_PROPS = !!'3.10.0-beta.1';
export const MOUSE_ENTER_LEAVE_MOVE_EVENTS = !!'3.13.0-beta.1';
export const ASSIGN = !!'4.0.0-beta.1';
4 changes: 0 additions & 4 deletions packages/ember/tests/reexports_test.js
Expand Up @@ -3,7 +3,6 @@ import require from 'require';
import { EMBER_MODERNIZED_BUILT_IN_COMPONENTS, FEATURES } from '@ember/canary-features';
import { AbstractTestCase, confirmExport, moduleFor } from 'internal-test-helpers';
import { DEBUG } from '@glimmer/env';
import { ENV } from '@ember/-internals/environment';

moduleFor(
'ember reexports',
Expand Down Expand Up @@ -443,9 +442,6 @@ let allExports = [
// backburner
['_Backburner', 'backburner', 'default'],

// jquery
ENV._JQUERY_INTEGRATION ? [null, 'jquery', 'default'] : null,

// rsvp
[null, 'rsvp', 'default'],
[null, 'rsvp', 'Promise'],
Expand Down
2 changes: 0 additions & 2 deletions tests/docs/expected.js
Expand Up @@ -11,7 +11,6 @@ module.exports = {
'_APPLICATION_TEMPLATE_WRAPPER',
'_DISABLE_PROPERTY_FALLBACK_DEPRECATION',
'_DEBUG_RENDER_TREE',
'_JQUERY_INTEGRATION',
'_DEFAULT_ASYNC_OBSERVERS',
'_RERENDER_LOOP_LIMIT',
'_TEMPLATE_ONLY_GLIMMER_COMPONENTS',
Expand Down Expand Up @@ -326,7 +325,6 @@ module.exports = {
'isRejected',
'isSettled',
'join',
'jQuery',
'keyDown',
'keyPress',
'keyUp',
Expand Down