diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-02-01 18:06:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-01 18:06:11 +0100 |
commit | 8176a4d1663529fb8aeebf7734c4994fa1d583f4 (patch) | |
tree | 94c7d6eb2679e641f59cf78640340f5b7af0022e /ext/fetch/23_response.js | |
parent | abf89f8c4675ed78c992fafd6d758bf4bfca8a1a (diff) |
refactor: primordials for instanceof (#13527)
Diffstat (limited to 'ext/fetch/23_response.js')
-rw-r--r-- | ext/fetch/23_response.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js index e7b205418..14aadbaf2 100644 --- a/ext/fetch/23_response.js +++ b/ext/fetch/23_response.js @@ -33,6 +33,7 @@ MapPrototypeHas, MapPrototypeGet, MapPrototypeSet, + ObjectPrototypeIsPrototypeOf, RangeError, RegExp, RegExpPrototypeTest, @@ -297,7 +298,7 @@ * @returns {"basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"} */ get type() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); return this[_response].type; } @@ -305,7 +306,7 @@ * @returns {string} */ get url() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); const url = this[_response].url(); if (url === null) return ""; const newUrl = new URL(url); @@ -317,7 +318,7 @@ * @returns {boolean} */ get redirected() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); return this[_response].urlList.length > 1; } @@ -325,7 +326,7 @@ * @returns {number} */ get status() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); return this[_response].status; } @@ -333,7 +334,7 @@ * @returns {boolean} */ get ok() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); const status = this[_response].status; return status >= 200 && status <= 299; } @@ -342,7 +343,7 @@ * @returns {string} */ get statusText() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); return this[_response].statusMessage; } @@ -350,7 +351,7 @@ * @returns {Headers} */ get headers() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); return this[_headers]; } @@ -358,7 +359,7 @@ * @returns {Response} */ clone() { - webidl.assertBranded(this, Response); + webidl.assertBranded(this, ResponsePrototype); if (this[_body] && this[_body].unusable()) { throw new TypeError("Body is unusable."); } @@ -375,7 +376,7 @@ [SymbolFor("Deno.customInspect")](inspect) { return inspect(consoleInternal.createFilteredInspectProxy({ object: this, - evaluate: this instanceof Response, + evaluate: ObjectPrototypeIsPrototypeOf(ResponsePrototype, this), keys: [ "body", "bodyUsed", @@ -390,13 +391,13 @@ } } - mixinBody(Response, _body, _mimeType); - webidl.configurePrototype(Response); + const ResponsePrototype = Response.prototype; + mixinBody(ResponsePrototype, _body, _mimeType); webidl.converters["Response"] = webidl.createInterfaceConverter( "Response", - Response, + ResponsePrototype, ); webidl.converters["ResponseInit"] = webidl.createDictionaryConverter( "ResponseInit", @@ -457,6 +458,7 @@ window.__bootstrap.fetch ??= {}; window.__bootstrap.fetch.Response = Response; + window.__bootstrap.fetch.ResponsePrototype = ResponsePrototype; window.__bootstrap.fetch.newInnerResponse = newInnerResponse; window.__bootstrap.fetch.toInnerResponse = toInnerResponse; window.__bootstrap.fetch.fromInnerResponse = fromInnerResponse; |