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 all Internet Explorer support into a pit of flames! 🔥 IE 🔥 #7184

Merged
merged 1 commit into from Mar 7, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 0 additions & 45 deletions spec/observables/dom/ajax-spec.ts
Expand Up @@ -330,37 +330,6 @@ describe('ajax', () => {
expect(complete).to.be.true;
});

it('should fail if fails to parse response in older IE', () => {
let error: any;
const obj: AjaxConfig = {
url: '/flibbertyJibbet',
method: '',
};

// No `response` property on the object (for older IE).
MockXMLHttpRequest.noResponseProp = true;

ajax(obj).subscribe({
next: () => {
throw new Error('should not next');
},
error: (err: any) => {
error = err;
},
complete: () => {
throw new Error('should not complete');
},
});

MockXMLHttpRequest.mostRecent.respondWith({
status: 207,
responseText: 'Wee! I am text, but should be valid JSON!',
});

expect(error instanceof SyntaxError).to.be.true;
expect(error.message).to.equal('Unexpected token W in JSON at position 0');
});

it('should fail on 404', () => {
let error: any;
const obj: AjaxConfig = {
Expand Down Expand Up @@ -1583,11 +1552,6 @@ class MockXHREventTarget {
class MockXMLHttpRequest extends MockXHREventTarget {
static readonly DONE = 4;

/**
* Set to `true` to test IE code paths.
*/
static noResponseProp = false;

private static requests: Array<MockXMLHttpRequest> = [];
private static recentRequest: MockXMLHttpRequest;

Expand All @@ -1600,7 +1564,6 @@ class MockXMLHttpRequest extends MockXHREventTarget {
}

static clearRequest(): void {
MockXMLHttpRequest.noResponseProp = false;
MockXMLHttpRequest.requests.length = 0;
MockXMLHttpRequest.recentRequest = null!;
}
Expand Down Expand Up @@ -1639,9 +1602,6 @@ class MockXMLHttpRequest extends MockXHREventTarget {
super();
MockXMLHttpRequest.recentRequest = this;
MockXMLHttpRequest.requests.push(this);
if (MockXMLHttpRequest.noResponseProp) {
delete this['response'];
}
}

// @ts-ignore: Property has no initializer and is not definitely assigned
Expand Down Expand Up @@ -1755,11 +1715,6 @@ class MockXMLHttpRequest extends MockXHREventTarget {
break;
}

// We're testing old IE, forget all of that response property stuff.
if (MockXMLHttpRequest.noResponseProp) {
delete this['response'];
}

this.triggerEvent('load', { type: 'load', total: response.total ?? 0, loaded: response.loaded ?? 0 });
this.triggerEvent('readystatechange', { type: 'readystatechange' });
}
Expand Down
3 changes: 1 addition & 2 deletions src/internal/ajax/AjaxResponse.ts
@@ -1,5 +1,4 @@
import { AjaxRequest, AjaxResponseType } from './types';
import { getXHRResponse } from './getXHRResponse';

/**
* A normalized response from an AJAX request. To get the data from the response,
Expand Down Expand Up @@ -116,7 +115,7 @@ export class AjaxResponse<T> {
}, {})
: {};

this.response = getXHRResponse(xhr);
this.response = xhr.response;
const { loaded, total } = originalEvent;
this.loaded = loaded;
this.total = total;
Expand Down
13 changes: 1 addition & 12 deletions src/internal/ajax/ajax.ts
Expand Up @@ -481,18 +481,7 @@ export function fromAjax<T>(init: AjaxConfig): Observable<AjaxResponse<T>> {
if (status < 400) {
progressSubscriber?.complete?.();

let response: AjaxResponse<T>;
try {
// This can throw in IE, because we end up needing to do a JSON.parse
// of the response in some cases to produce object we'd expect from
// modern browsers.
response = createResponse(DOWNLOAD, event);
} catch (err) {
destination.error(err);
return;
}

destination.next(response);
destination.next(createResponse(DOWNLOAD, event));
destination.complete();
} else {
progressSubscriber?.error?.(event);
Expand Down
11 changes: 1 addition & 10 deletions src/internal/ajax/errors.ts
@@ -1,5 +1,4 @@
import { AjaxRequest } from './types';
import { getXHRResponse } from './getXHRResponse';
import { createErrorClass } from '../util/createErrorClass';

/**
Expand Down Expand Up @@ -63,15 +62,7 @@ export const AjaxError: AjaxErrorCtor = createErrorClass(
this.request = request;
this.status = xhr.status;
this.responseType = xhr.responseType;
let response: any;
try {
// This can throw in IE, because we have to do a JSON.parse of
// the response in some cases to get the expected response property.
response = getXHRResponse(xhr);
} catch (err) {
response = xhr.responseText;
}
this.response = response;
this.response = xhr.response;
}
);

Expand Down
37 changes: 0 additions & 37 deletions src/internal/ajax/getXHRResponse.ts

This file was deleted.