Support responseType property on XMLHttpRequest.

Only default, "" and "text" supported for now. Raising an error otherwise.
This commit is contained in:
Hristo Deshev
2015-06-15 15:25:43 +03:00
parent f109cbe80b
commit 51a56a2aea
3 changed files with 27 additions and 0 deletions

View File

@ -49,6 +49,7 @@ export class XMLHttpRequest {
private _responseText: string = "";
private _headers: any;
private _errorFlag: boolean;
private _responseType: string;
public onreadystatechange: Function;
@ -163,6 +164,18 @@ export class XMLHttpRequest {
return this._readyState;
}
public get responseType(): string {
return this._responseType;
}
public set responseType(value: string) {
if (value === "" || value === "text") {
this._responseType = value;
} else {
throw new Error(`Response type of '${value}' not supported.`);
}
}
private _setReadyState(value: number) {
if (this._readyState !== value) {
this._readyState = value;