Skip to content

Commit

Permalink
Fix Ember global deprecation
Browse files Browse the repository at this point in the history
A minimal fix for #600. We should probably follow through with the
refactor suggested by @rwjblue in #600 but that can be done later.

This is probably not very embroider friendly, but neither is the
current code. It's probably easier to just rewrite the shims in
terms of ES modules and embroider macros, i.e. what was suggested
in #337.
  • Loading branch information
chancancode committed Jun 2, 2021
1 parent 3e02036 commit 45b49d8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions assets/browser-fetch.js.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
(function (originalGlobal) {
define('fetch', ['exports'], function(exports) {
if (!require.has('ember')) {
define('ember', ['exports'], function(exports) {
exports['default'] = originalGlobal.Ember;
});
}

define('fetch', ['exports', 'ember'], function(exports, Ember) {
'use strict';
var Promise = originalGlobal.Ember.RSVP.Promise;
var Ember__default = 'default' in Ember ? Ember['default'] : Ember;
var Promise = Ember__default.RSVP.Promise;
var supportProps = [
'FormData',
'FileReader',
Expand Down Expand Up @@ -49,8 +56,8 @@
return result;
}

if (originalGlobal.Ember.Test) {
originalGlobal.Ember.Test.registerWaiter(function() {
if (Ember__default.Test) {
Ember__default.Test.registerWaiter(function() {
return pending === 0;
});

Expand Down

0 comments on commit 45b49d8

Please sign in to comment.