Skip to content

Commit

Permalink
Remove internal jQuery usage
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Aug 18, 2021
1 parent 747f5ff commit 3e4d387
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 105 deletions.
14 changes: 0 additions & 14 deletions packages/@ember/-internals/environment/lib/env.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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);
}
}
}

export default Application;
8 changes: 1 addition & 7 deletions packages/@ember/application/tests/application_test.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 3e4d387

Please sign in to comment.