Skip to content

Commit

Permalink
Deprecate window.ENV
Browse files Browse the repository at this point in the history
  • Loading branch information
astronomersiva committed Oct 1, 2019
1 parent 8481adf commit 6bf16b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
17 changes: 16 additions & 1 deletion packages/@ember/-internals/environment/lib/env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { deprecate } from '@ember/debug';
import { FUNCTION_PROTOTYPE_EXTENSIONS } from '@ember/deprecated-features';
import { DEBUG } from '@glimmer/env';
import global from './global';
Expand Down Expand Up @@ -182,6 +183,20 @@ export const ENV = {
},
};

let providedEnv = global.EmberENV;
if (providedEnv === undefined) {
providedEnv = global.ENV;

deprecate(
"Configuring Ember's boot options via `window.ENV` is deprecated, please migrate to `window.EmberENV` instead.",
providedEnv === undefined,
{
id: 'ember-environment.window.env',
until: '3.17.0',
}
);
}

(EmberENV => {
if (typeof EmberENV !== 'object' || EmberENV === null) return;

Expand Down Expand Up @@ -241,7 +256,7 @@ export const ENV = {
if (DEBUG) {
ENV._DEBUG_RENDER_TREE = true;
}
})(global.EmberENV || global.ENV);
})(providedEnv);

export function getENV() {
return ENV;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,21 @@ export default function addJQueryEventDeprecation(jqEvent) {
return new Proxy(jqEvent, {
get(target, name) {
switch (name) {
case 'originalEvent':
case 'originalEvent': {
let providedEnv = global.EmberENV;
if (providedEnv === undefined) {
providedEnv = global.ENV;

deprecate(
"Configuring Ember's boot options via `window.ENV` is deprecated, please migrate to `window.EmberENV` instead.",
providedEnv === undefined,
{
id: 'ember-environment.window.env',
until: '3.17.0',
}
);
}

deprecate(
'Accessing jQuery.Event specific properties is deprecated. Either use the ember-jquery-legacy addon to normalize events to native events, or explicitly opt into jQuery integration using @ember/optional-features.',
(EmberENV => {
Expand All @@ -27,14 +41,15 @@ export default function addJQueryEventDeprecation(jqEvent) {
if (typeof EmberENV !== 'object' || EmberENV === null) return false;

return EmberENV._JQUERY_INTEGRATION === true;
})(global.EmberENV || global.ENV),
})(providedEnv),
{
id: 'ember-views.event-dispatcher.jquery-event',
until: '4.0.0',
url: 'https://emberjs.com/deprecations/v3.x#toc_jquery-event',
}
);
return target[name];
}

// provide an escape hatch for ember-jquery-legacy to access originalEvent without a deprecation
case '__originalEvent':
Expand Down

0 comments on commit 6bf16b9

Please sign in to comment.