mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Move XMLHttpRequest#responseText to a getter
Moving this property to a getter lets the implementation of the object change the value but prevents clients of the API from changing the value, which is the expected behavior. R=esprehn@chromium.org Review URL: https://codereview.chromium.org/746953002
This commit is contained in:
parent
1766fb0ba7
commit
a2aedc2d68
@ -16,13 +16,13 @@ class Private {
|
||||
this.request = null;
|
||||
this.loader = null;
|
||||
this.headers = new Map();
|
||||
this.responseText = "";
|
||||
}
|
||||
}
|
||||
|
||||
class XMLHttpRequest {
|
||||
constructor() {
|
||||
this[kPrivate] = new Private;
|
||||
this.responseText = null;
|
||||
}
|
||||
|
||||
onload() {
|
||||
@ -31,6 +31,10 @@ class XMLHttpRequest {
|
||||
onerror(error) {
|
||||
}
|
||||
|
||||
get responseText() {
|
||||
return this[kPrivate].responseText;
|
||||
}
|
||||
|
||||
open(method, url) {
|
||||
var request = new loader.URLRequest();
|
||||
request.url = new URL(url, document.URL);
|
||||
@ -64,7 +68,7 @@ class XMLHttpRequest {
|
||||
priv.loader.start(priv.request).then(function(result) {
|
||||
return core.drainData(result.response.body).then(function(result) {
|
||||
outstandingRequests.delete(self);
|
||||
self.responseText = unicode.decodeUtf8String(new Uint8Array(result.buffer));
|
||||
priv.responseText = unicode.decodeUtf8String(new Uint8Array(result.buffer));
|
||||
self.onload();
|
||||
});
|
||||
}).catch(function(error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user