Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop ie11 code #1539

Merged
merged 3 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1060,12 +1060,12 @@ export class InitialRenderSuite extends RenderTest {
@test
'Integer powers of 2'() {
const ints = [];
let i = 9007199254740991; // Number.MAX_SAFE_INTEGER isn't available on IE11
let i = Number.MAX_SAFE_INTEGER;
while (i > 1) {
ints.push(i);
i = Math.round(i / 2);
}
i = -9007199254740991; // Number.MIN_SAFE_INTEGER isn't available on IE11
i = Number.MIN_SAFE_INTEGER;
while (i < -1) {
ints.push(i);
i = Math.round(i / 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ import {
test,
} from '..';

// `window.ActiveXObject` is "falsey" in IE11 (but not `undefined` or `false`)
// `"ActiveXObject" in window` returns `true` in all IE versions
// only IE11 will pass _both_ of these conditions
const isIE11 = !(window as any).ActiveXObject && 'ActiveXObject' in window;

abstract class AbstractChaosMonkeyTest extends RenderTest {
abstract renderClientSide(template: string | ComponentBlueprint, context: Dict<unknown>): void;

Expand Down Expand Up @@ -247,13 +242,7 @@ class ChaosMonkeyRehydration extends AbstractChaosMonkeyTest {
const b = blockStack();

// assert that we are in a "browser corrected" state (note the `</p>` before the `<div>world!</div>`)
if (isIE11) {
// IE11 doesn't behave the same as modern browsers
this.assertServerOutput(`<p>hello ${b(1)}<div>world!</div>${b(1)}<p></p>`);
} else {
this.assertServerOutput(`<p>hello ${b(1)}</p><div>world!</div>${b(1)}<p></p>`);
}

this.assertServerOutput(`<p>hello ${b(1)}</p><div>world!</div>${b(1)}<p></p>`);
this.runIterations(template, context, '<p>hello <div>world!</div></p>', 100);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ import {
toTextContent,
} from '..';

// `window.ActiveXObject` is "falsey" in IE11 (but not `undefined` or `false`)
// `"ActiveXObject" in window` returns `true` in all IE versions
// only IE11 will pass _both_ of these conditions
const isIE11 = !(window as any).ActiveXObject && 'ActiveXObject' in window;

class RenderTests extends InitialRenderSuite {
static override suiteName = 'initial render (client)';
override name = 'client';
Expand Down Expand Up @@ -1062,13 +1057,7 @@ class RehydratingComponents extends AbstractRehydrationTests {

let id = this.testType === 'Dynamic' ? 3 : 2;

// assert that we are in a "browser corrected" state (note the `</p>` before the `<div>world!</div>`)
if (isIE11) {
// IE11 doesn't behave the same as modern browsers
this.assertServerComponent(`<p>hello ${b(id)}<div>world!</div>${b(id)}<p></p>`);
} else {
this.assertServerComponent(`<p>hello ${b(id)}</p><div>world!</div>${b(id)}<p></p>`);
}
this.assertServerComponent(`<p>hello ${b(id)}</p><div>world!</div>${b(id)}<p></p>`);

this.renderClientSide(componentToRender, { show: true });
this.assertComponent('<p>hello <div>world!</div></p>');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const isChrome = hasDom
? typeof global.chrome === 'object' && !(typeof global.opera === 'object')
: false;
const isFirefox = hasDom ? /Firefox|FxiOS/u.test(navigator.userAgent) : false;
const isIE11 = !global.ActiveXObject && 'ActiveXObject' in window;

interface Counters {
adds: number;
Expand Down Expand Up @@ -82,8 +81,6 @@ if (hasDom) {

if (isChrome || isFirefox) {
assert.strictEqual(SUPPORTS_EVENT_OPTIONS, true, 'is true in chrome and firefox');
} else if (isIE11) {
assert.strictEqual(SUPPORTS_EVENT_OPTIONS, false, 'is false in IE11');
}
}

Expand Down Expand Up @@ -189,11 +186,7 @@ if (hasDom) {

assert.strictEqual(count, 1, 'has been called 1 times');

if (isIE11) {
this.assertCounts({ adds: 1, removes: 1 });
} else {
this.assertCounts({ adds: 1, removes: 0 });
}
this.assertCounts({ adds: 1, removes: 0 });
}

@test
Expand Down Expand Up @@ -226,11 +219,7 @@ if (hasDom) {
button.click();
assert.strictEqual(count, 3, 'is not called again');

if (isIE11) {
this.assertCounts({ adds: 2, removes: 2 });
} else {
this.assertCounts({ adds: 2, removes: 1 });
}
this.assertCounts({ adds: 2, removes: 1 });
}

@test
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/debug/lib/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function strip(strings: TemplateStringsArray, ...args: unknown[]) {
// eslint-disable-next-line regexp/no-super-linear-backtracking
out = /^\s*?\n?([\s\S]*?)\s*$/u.exec(out)![1] as string;

let min = 9007199254740991; // Number.MAX_SAFE_INTEGER isn't available on IE11
let min = Number.MAX_SAFE_INTEGER;

for (let line of out.split('\n')) {
let leading = /^\s*/u.exec(line)![0].length;
Expand Down
98 changes: 50 additions & 48 deletions packages/@glimmer/runtime/lib/dom/sanitized-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,55 +37,57 @@ interface NodeUrlModule {
parse(url: string): NodeUrlParseResult;
}

let protocolForUrl: (url: string) => string;

if (
typeof URL === 'object' &&
URL !== null &&
// this is super annoying, TS thinks that URL **must** be a function so `URL.parse` check
// thinks it is `never` without this `as unknown as any`
typeof (URL as unknown as any).parse === 'function'
) {
// In Ember-land the `fastboot` package sets the `URL` global to `require('url')`
// ultimately, this should be changed (so that we can either rely on the natural `URL` global
// that exists) but for now we have to detect the specific `FastBoot` case first
//
// a future version of `fastboot` will detect if this legacy URL setup is required (by
// inspecting Ember version) and if new enough, it will avoid shadowing the `URL` global
// constructor with `require('url')`.
let nodeURL = URL as NodeUrlModule;

protocolForUrl = (url: string) => {
let protocol = null;

if (typeof url === 'string') {
protocol = nodeURL.parse(url).protocol;
}
function findProtocolForURL() {
if (
typeof URL === 'object' &&
URL !== null &&
// this is super annoying, TS thinks that URL **must** be a function so `URL.parse` check
// thinks it is `never` without this `as unknown as any`
typeof (URL as unknown as any).parse === 'function'
) {
// In Ember-land the `fastboot` package sets the `URL` global to `require('url')`
// ultimately, this should be changed (so that we can either rely on the natural `URL` global
// that exists) but for now we have to detect the specific `FastBoot` case first
//
// a future version of `fastboot` will detect if this legacy URL setup is required (by
// inspecting Ember version) and if new enough, it will avoid shadowing the `URL` global
// constructor with `require('url')`.
let nodeURL = URL as NodeUrlModule;

return (url: string) => {
let protocol = null;

if (typeof url === 'string') {
protocol = nodeURL.parse(url).protocol;
}

return protocol === null ? ':' : protocol;
};
} else if (typeof URL === 'function') {
return (_url: string) => {
try {
let url = new URL(_url);

return url.protocol;
} catch (error) {
// any non-fully qualified url string will trigger an error (because there is no
// baseURI that we can provide; in that case we **know** that the protocol is
// "safe" because it isn't specifically one of the `badProtocols` listed above
// (and those protocols can never be the default baseURI)
return ':';
}
};
} else {
throw new Error(`@glimmer/runtime needs a valid "globalThis.URL"`);
}
}

return protocol === null ? ':' : protocol;
};
} else if (typeof URL === 'function') {
protocolForUrl = (_url: string) => {
try {
let url = new URL(_url);

return url.protocol;
} catch (error) {
// any non-fully qualified url string will trigger an error (because there is no
// baseURI that we can provide; in that case we **know** that the protocol is
// "safe" because it isn't specifically one of the `badProtocols` listed above
// (and those protocols can never be the default baseURI)
return ':';
}
};
} else {
// fallback for IE11 support
let parsingNode = document.createElement('a');

protocolForUrl = (url: string) => {
parsingNode.href = url;
return parsingNode.protocol;
};
let _protocolForUrlImplementation: typeof protocolForUrl | undefined;
function protocolForUrl(url: string): string {
if (!_protocolForUrlImplementation) {
_protocolForUrlImplementation = findProtocolForURL();
}
return _protocolForUrlImplementation(url);
}

export function sanitizeAttributeValue(
Expand Down
12 changes: 3 additions & 9 deletions packages/@glimmer/util/test/debug-to-string-test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { debugToString as maybeDebugToString } from '@glimmer/util';
// `window.ActiveXObject` is "falsey" in IE11 (but not `undefined` or `false`)
// `"ActiveXObject" in window` returns `true` in all IE versions
// only IE11 will pass _both_ of these conditions
const isIE11 = !(window as any).ActiveXObject && 'ActiveXObject' in window;

QUnit.module('debug-to-string tests');

Expand Down Expand Up @@ -37,11 +33,9 @@ if (import.meta.env.DEV) {
QUnit.test('should return debug name for primitive [Infinity]', (assert) => {
assert.deepEqual(debugToString(Infinity), 'Infinity');
});
if (!isIE11) {
QUnit.test('should return debug name for primitive [Symbol]', (assert) => {
assert.deepEqual(debugToString(Symbol('Foo')), 'Symbol(Foo)');
});
}
QUnit.test('should return debug name for primitive [Symbol]', (assert) => {
assert.deepEqual(debugToString(Symbol('Foo')), 'Symbol(Foo)');
});
QUnit.test('should return debug name for object', (assert) => {
assert.deepEqual(debugToString({}), 'Object');
});
Expand Down
3 changes: 1 addition & 2 deletions packages/@glimmer/validator/lib/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,7 @@ if (import.meta.env.DEV) {
current = current.parent;
}

// TODO: Use String.prototype.repeat here once we can drop support for IE11
return trackingStack.map((label, index) => Array(2 * index + 1).join(' ') + label).join('\n');
return trackingStack.map((label, index) => ' '.repeat(2 * index) + label).join('\n');
};

debug.markTagAsConsumed = (_tag: Tag) => {
Expand Down
Loading