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
refactor(http): remove all facade methods from http module #12870
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,26 +14,21 @@ import {JSONPBackend, JSONPBackend_, JSONPConnection, JSONPConnection_} from '.. | |
import {BaseRequestOptions, RequestOptions} from '../../src/base_request_options'; | ||
import {BaseResponseOptions, ResponseOptions} from '../../src/base_response_options'; | ||
import {ReadyState, RequestMethod, ResponseType} from '../../src/enums'; | ||
import {isPresent} from '../../src/facade/lang'; | ||
import {Request} from '../../src/static_request'; | ||
|
||
let existingScripts: MockBrowserJsonp[] = []; | ||
|
||
class MockBrowserJsonp extends BrowserJsonp { | ||
src: string; | ||
callbacks = new Map<string, (data: any) => any>(); | ||
constructor() { super(); } | ||
|
||
addEventListener(type: string, cb: (data: any) => any) { this.callbacks.set(type, cb); } | ||
|
||
removeEventListener(type: string, cb: Function) { this.callbacks.delete(type); } | ||
|
||
dispatchEvent(type: string, argument?: any) { | ||
if (!isPresent(argument)) { | ||
argument = {}; | ||
} | ||
dispatchEvent(type: string, argument: any = {}) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wouldn't this change the public API ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a spec, so should be good There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, nv |
||
const cb = this.callbacks.get(type); | ||
if (isPresent(cb)) { | ||
if (cb) { | ||
cb(argument); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (typeof this._body === 'object' && this._body !== null ) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
is already being checked a few lines above. (;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right :)