Skip to content

Commit 54835c6

Browse files
Merge pull request #21204 from johanrd/cleanup/remove-old-browser-workarounds
[CLEANUP] Remove old browser workarounds, targeting Ember 6.x
2 parents dcfd69c + 4be5c06 commit 54835c6

33 files changed

Lines changed: 121 additions & 393 deletions

File tree

eslint.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ export default [
154154
Symbol: true,
155155
WeakMap: true,
156156
Event: true,
157+
MouseEvent: true,
158+
KeyboardEvent: true,
159+
DOMRect: true,
160+
DOMRectList: true,
161+
globalThis: true,
157162
},
158163

159164
ecmaVersion: 2017,
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export * from './lib/context';
22
export * from './lib/env';
3-
export { default as global } from './lib/global';

packages/@ember/-internals/environment/lib/context.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import global from './global';
2-
31
export interface GlobalContext {
42
imports: object;
53
exports: object;
64
lookup: Record<string, unknown>;
75
}
86

7+
const global = globalThis as Record<string, unknown>;
8+
const Ember = global['Ember'] as Partial<GlobalContext> | undefined;
9+
910
// legacy imports/exports/lookup stuff (should we keep this??)
10-
export const context = (function (
11-
global: Record<string, unknown>,
12-
Ember: Partial<GlobalContext> | undefined
13-
): GlobalContext {
14-
return Ember === undefined
11+
export const context: GlobalContext =
12+
Ember === undefined
1513
? { imports: global, exports: global, lookup: global }
1614
: {
1715
// import jQuery
@@ -21,7 +19,6 @@ export const context = (function (
2119
// search for Namespaces
2220
lookup: Ember.lookup || global,
2321
};
24-
})(global, global.Ember);
2522

2623
export function getLookup(): Record<string, unknown> {
2724
return context.lookup;

packages/@ember/-internals/environment/lib/env.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { DEBUG } from '@glimmer/env';
2-
import global from './global';
32

43
/**
54
The hash of environment variables used to control various configuration
@@ -154,15 +153,15 @@ export const ENV = {
154153
},
155154
};
156155

157-
((
158-
EmberENV: Record<string, unknown> & {
159-
EXTEND_PROTOTYPES?: boolean;
160-
EMBER_LOAD_HOOKS?: Record<string, unknown>;
161-
FEATURES?: Record<string, unknown>;
162-
}
163-
) => {
164-
if (typeof EmberENV !== 'object' || EmberENV === null) return;
156+
interface EmberENVConfig extends Record<string, unknown> {
157+
EXTEND_PROTOTYPES?: boolean;
158+
EMBER_LOAD_HOOKS?: Record<string, unknown>;
159+
FEATURES?: Record<string, unknown>;
160+
}
165161

162+
const EmberENV = (globalThis as { EmberENV?: EmberENVConfig }).EmberENV;
163+
164+
if (typeof EmberENV === 'object' && EmberENV !== null) {
166165
for (let flag in EmberENV) {
167166
if (
168167
!Object.prototype.hasOwnProperty.call(EmberENV, flag) ||
@@ -203,7 +202,7 @@ export const ENV = {
203202
if (DEBUG) {
204203
ENV._DEBUG_RENDER_TREE = true;
205204
}
206-
})(global.EmberENV);
205+
}
207206

208207
export function getENV(): object {
209208
return ENV;

packages/@ember/-internals/environment/lib/global.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

packages/@ember/-internals/glimmer/tests/integration/components/input-angle-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ class InputRenderingTest extends RenderingTestCase {
6161
}
6262

6363
triggerEvent(type, options, selector) {
64-
let event = document.createEvent('Events');
65-
event.initEvent(type, true, true);
64+
let event = new Event(type, { bubbles: true, cancelable: true });
6665
Object.assign(event, options);
6766

6867
let element = this.$(selector || 'input')[0];

packages/@ember/-internals/glimmer/tests/integration/components/input-curly-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ class InputRenderingTest extends RenderingTestCase {
6262
}
6363

6464
triggerEvent(type, options) {
65-
let event = document.createEvent('Events');
66-
event.initEvent(type, true, true);
65+
let event = new Event(type, { bubbles: true, cancelable: true });
6766
Object.assign(event, options);
6867

6968
let element = this.$input()[0];

packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-angle-test.js

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ import Engine from '@ember/engine';
1515
import { DEBUG } from '@glimmer/env';
1616
import { compile } from '../../../utils/helpers';
1717

18-
// IE includes the host name
19-
function normalizeUrl(url) {
20-
return url.replace(/https?:\/\/[^/]+/, '');
21-
}
22-
2318
function shouldNotBeActive(assert, element) {
2419
checkActive(assert, element, false);
2520
}
@@ -152,9 +147,7 @@ moduleFor(
152147
// SVGAElement does not have a .click() method like HTMLElement,
153148
// so we dispatch a click event manually.
154149
let svgLink = document.querySelector('#svg-about-link');
155-
let clickEvent = document.createEvent('MouseEvents');
156-
clickEvent.initMouseEvent('click', true, true);
157-
svgLink.dispatchEvent(clickEvent);
150+
svgLink.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
158151
await runLoopSettled();
159152

160153
assert.equal(this.$('h3.about').length, 1, 'The about template was rendered');
@@ -870,7 +863,7 @@ moduleFor(
870863

871864
await this.visit('/about/item');
872865

873-
assert.equal(normalizeUrl(this.$('#item a').attr('href')), '/about');
866+
assert.equal(this.$('#item a').attr('href'), '/about');
874867
}
875868

876869
async [`@test it supports custom, nested, current-when`](assert) {
@@ -1226,11 +1219,7 @@ moduleFor(
12261219
await this.visit('/about');
12271220

12281221
assert.equal(this.$('h3.list').length, 1, 'The home template was rendered');
1229-
assert.equal(
1230-
normalizeUrl(this.$('#home-link').attr('href')),
1231-
'/',
1232-
'The home link points back at /'
1233-
);
1222+
assert.equal(this.$('#home-link').attr('href'), '/', 'The home link points back at /');
12341223

12351224
await this.click('#yehuda');
12361225

@@ -1241,9 +1230,9 @@ moduleFor(
12411230

12421231
await this.click('#about-link');
12431232

1244-
assert.equal(normalizeUrl(this.$('li a#yehuda').attr('href')), '/item/yehuda');
1245-
assert.equal(normalizeUrl(this.$('li a#tom').attr('href')), '/item/tom');
1246-
assert.equal(normalizeUrl(this.$('li a#erik').attr('href')), '/item/erik');
1233+
assert.equal(this.$('li a#yehuda').attr('href'), '/item/yehuda');
1234+
assert.equal(this.$('li a#tom').attr('href'), '/item/tom');
1235+
assert.equal(this.$('li a#erik').attr('href'), '/item/erik');
12471236

12481237
await this.click('#erik');
12491238

@@ -1422,11 +1411,11 @@ moduleFor(
14221411

14231412
await this.visit('/filters/popular');
14241413

1425-
assert.equal(normalizeUrl(this.$('#link').attr('href')), '/filters/unpopular');
1426-
assert.equal(normalizeUrl(this.$('#path-link').attr('href')), '/filters/unpopular');
1427-
assert.equal(normalizeUrl(this.$('#post-path-link').attr('href')), '/post/123');
1428-
assert.equal(normalizeUrl(this.$('#post-number-link').attr('href')), '/post/123');
1429-
assert.equal(normalizeUrl(this.$('#repo-object-link').attr('href')), '/repo/ember/ember.js');
1414+
assert.equal(this.$('#link').attr('href'), '/filters/unpopular');
1415+
assert.equal(this.$('#path-link').attr('href'), '/filters/unpopular');
1416+
assert.equal(this.$('#post-path-link').attr('href'), '/post/123');
1417+
assert.equal(this.$('#post-number-link').attr('href'), '/post/123');
1418+
assert.equal(this.$('#repo-object-link').attr('href'), '/repo/ember/ember.js');
14301419
}
14311420

14321421
async [`@test [GH#4201] Shorthand for route.index shouldn't throw errors about context arguments`](
@@ -1494,8 +1483,8 @@ moduleFor(
14941483
);
14951484

14961485
let assertEquality = (href) => {
1497-
assert.equal(normalizeUrl(this.$('#string-link').attr('href')), '/');
1498-
assert.equal(normalizeUrl(this.$('#path-link').attr('href')), href);
1486+
assert.equal(this.$('#string-link').attr('href'), '/');
1487+
assert.equal(this.$('#path-link').attr('href'), href);
14991488
};
15001489

15011490
await this.visit('/');
@@ -1537,7 +1526,7 @@ moduleFor(
15371526
runTask(() => controller.set('post', post));
15381527

15391528
assert.equal(
1540-
normalizeUrl(this.$('#post').attr('href')),
1529+
this.$('#post').attr('href'),
15411530
'/posts/1',
15421531
'precond - Link has rendered href attr properly'
15431532
);
@@ -1631,9 +1620,8 @@ moduleFor(
16311620
let idx;
16321621
for (idx = 0; idx < links.length; idx++) {
16331622
let href = this.$(links[idx]).attr('href');
1634-
// Old IE includes the whole hostname as well
16351623
assert.equal(
1636-
href.slice(-expected[idx].length),
1624+
href,
16371625
expected[idx],
16381626
`Expected link to be '${expected[idx]}', but was '${href}'`
16391627
);
@@ -1941,10 +1929,10 @@ moduleFor(
19411929

19421930
function assertLinkStatus(link, url) {
19431931
if (url) {
1944-
assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href');
1932+
assert.equal(link.attr('href'), url, 'loaded link-to has expected href');
19451933
assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass');
19461934
} else {
1947-
assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'");
1935+
assert.equal(link.attr('href'), '#', "unloaded link-to has href='#'");
19481936
assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass');
19491937
}
19501938
}

packages/@ember/-internals/glimmer/tests/integration/components/link-to/routing-curly-test.js

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ import Engine from '@ember/engine';
1414
import { DEBUG } from '@glimmer/env';
1515
import { compile } from '../../../utils/helpers';
1616

17-
// IE includes the host name
18-
function normalizeUrl(url) {
19-
return url.replace(/https?:\/\/[^/]+/, '');
20-
}
21-
2217
function shouldNotBeActive(assert, element) {
2318
checkActive(assert, element, false);
2419
}
@@ -911,7 +906,7 @@ moduleFor(
911906

912907
await this.visit('/about/item');
913908

914-
assert.equal(normalizeUrl(this.$('#item a').attr('href')), '/about');
909+
assert.equal(this.$('#item a').attr('href'), '/about');
915910
}
916911

917912
async [`@test it supports custom, nested, current-when`](assert) {
@@ -1222,11 +1217,7 @@ moduleFor(
12221217
await this.visit('/about');
12231218

12241219
assert.equal(this.$('h3.list').length, 1, 'The home template was rendered');
1225-
assert.equal(
1226-
normalizeUrl(this.$('#home-link > a').attr('href')),
1227-
'/',
1228-
'The home link points back at /'
1229-
);
1220+
assert.equal(this.$('#home-link > a').attr('href'), '/', 'The home link points back at /');
12301221

12311222
await this.click('#yehuda > a');
12321223

@@ -1237,9 +1228,9 @@ moduleFor(
12371228

12381229
await this.click('#about-link > a');
12391230

1240-
assert.equal(normalizeUrl(this.$('li#yehuda > a').attr('href')), '/item/yehuda');
1241-
assert.equal(normalizeUrl(this.$('li#tom > a').attr('href')), '/item/tom');
1242-
assert.equal(normalizeUrl(this.$('li#erik > a').attr('href')), '/item/erik');
1231+
assert.equal(this.$('li#yehuda > a').attr('href'), '/item/yehuda');
1232+
assert.equal(this.$('li#tom > a').attr('href'), '/item/tom');
1233+
assert.equal(this.$('li#erik > a').attr('href'), '/item/erik');
12431234

12441235
await this.click('#erik > a');
12451236

@@ -1292,14 +1283,11 @@ moduleFor(
12921283

12931284
await this.visit('/filters/popular');
12941285

1295-
assert.equal(normalizeUrl(this.$('#link > a').attr('href')), '/filters/unpopular');
1296-
assert.equal(normalizeUrl(this.$('#path-link > a').attr('href')), '/filters/unpopular');
1297-
assert.equal(normalizeUrl(this.$('#post-path-link > a').attr('href')), '/post/123');
1298-
assert.equal(normalizeUrl(this.$('#post-number-link > a').attr('href')), '/post/123');
1299-
assert.equal(
1300-
normalizeUrl(this.$('#repo-object-link > a').attr('href')),
1301-
'/repo/ember/ember.js'
1302-
);
1286+
assert.equal(this.$('#link > a').attr('href'), '/filters/unpopular');
1287+
assert.equal(this.$('#path-link > a').attr('href'), '/filters/unpopular');
1288+
assert.equal(this.$('#post-path-link > a').attr('href'), '/post/123');
1289+
assert.equal(this.$('#post-number-link > a').attr('href'), '/post/123');
1290+
assert.equal(this.$('#repo-object-link > a').attr('href'), '/repo/ember/ember.js');
13031291
}
13041292

13051293
async [`@test [GH#4201] Shorthand for route.index shouldn't throw errors about context arguments`](
@@ -1367,8 +1355,8 @@ moduleFor(
13671355
);
13681356

13691357
let assertEquality = (href) => {
1370-
assert.equal(normalizeUrl(this.$('#string-link > a').attr('href')), '/');
1371-
assert.equal(normalizeUrl(this.$('#path-link > a').attr('href')), href);
1358+
assert.equal(this.$('#string-link > a').attr('href'), '/');
1359+
assert.equal(this.$('#path-link > a').attr('href'), href);
13721360
};
13731361

13741362
await this.visit('/');
@@ -1410,7 +1398,7 @@ moduleFor(
14101398
runTask(() => controller.set('post', post));
14111399

14121400
assert.equal(
1413-
normalizeUrl(this.$('#post > a').attr('href')),
1401+
this.$('#post > a').attr('href'),
14141402
'/posts/1',
14151403
'precond - Link has rendered href attr properly'
14161404
);
@@ -1504,9 +1492,8 @@ moduleFor(
15041492
let idx;
15051493
for (idx = 0; idx < links.length; idx++) {
15061494
let href = this.$(links[idx]).attr('href');
1507-
// Old IE includes the whole hostname as well
15081495
assert.equal(
1509-
href.slice(-expected[idx].length),
1496+
href,
15101497
expected[idx],
15111498
`Expected link to be '${expected[idx]}', but was '${href}'`
15121499
);
@@ -1828,10 +1815,10 @@ moduleFor(
18281815

18291816
function assertLinkStatus(link, url) {
18301817
if (url) {
1831-
assert.equal(normalizeUrl(link.attr('href')), url, 'loaded link-to has expected href');
1818+
assert.equal(link.attr('href'), url, 'loaded link-to has expected href');
18321819
assert.ok(!link.hasClass('i-am-loading'), 'loaded linkComponent has no loadingClass');
18331820
} else {
1834-
assert.equal(normalizeUrl(link.attr('href')), '#', "unloaded link-to has href='#'");
1821+
assert.equal(link.attr('href'), '#', "unloaded link-to has href='#'");
18351822
assert.ok(link.hasClass('i-am-loading'), 'loading linkComponent has loadingClass');
18361823
}
18371824
}

packages/@ember/-internals/glimmer/tests/integration/components/textarea-angle-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class TextAreaRenderingTest extends RenderingTestCase {
1616
}
1717

1818
triggerEvent(type, options = {}) {
19-
let event = document.createEvent('Events');
20-
event.initEvent(type, true, true);
19+
let event = new Event(type, { bubbles: true, cancelable: true });
2120
Object.assign(event, options);
2221

2322
this.firstChild.dispatchEvent(event);

0 commit comments

Comments
 (0)