Skip to content

Commit

Permalink
WIP: Deprecate window global
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 25, 2021
1 parent f2be195 commit e0fdb0f
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions packages/ember/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ import {
const Ember = (typeof context.imports.Ember === 'object' && context.imports.Ember) || {};

Ember.isNamespace = true;
Ember.toString = function () {
Ember.toString = function() {
return 'Ember';
};

Expand Down Expand Up @@ -457,7 +457,7 @@ Ember.isEqual = isEqual;
Ember.inject = function inject() {
assert(
`Injected properties must be created through helpers, see '${Object.keys(inject)
.map((k) => `'inject.${k}'`)
.map(k => `'inject.${k}'`)
.join(' or ')}'`
);
};
Expand Down Expand Up @@ -647,11 +647,11 @@ Ember.HTMLBars = {
};

if (ENV.EXTEND_PROTOTYPES.String) {
String.prototype.htmlSafe = function () {
String.prototype.htmlSafe = function() {
return htmlSafe(this);
};
}
const deprecateImportFromString = function (
const deprecateImportFromString = function(
name,
message = `Importing ${name} from '@ember/string' is deprecated. Please import ${name} from '@ember/template' instead.`
) {
Expand Down Expand Up @@ -791,6 +791,36 @@ if (IS_NODE) {
context.exports.Ember = context.exports.Em = Ember;
}

if (window) {
Object.defineProperty(window, 'Ember', {
configurable: true,
writable: true,
get() {
deprecate(
"Using window.Ember has been deprecated. Use `import Ember from 'ember';` instead ",
false,
{
id: 'ember-source.window-global',
until: '4.0.0',
url: 'tbd',
for: 'ember-source',
since: { enabled: '3.26.0-beta.1' },
}
);

Object.defineProperty(window, 'Ember', {
configurable: true,
writable: false,
get() {
return Ember;
},
});

return Ember;
},
});
}

/**
@module jquery
@public
Expand Down

0 comments on commit e0fdb0f

Please sign in to comment.