diff options
Diffstat (limited to 'ext/fetch/23_request.js')
-rw-r--r-- | ext/fetch/23_request.js | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 5294009ff..5783cac9e 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -26,7 +26,7 @@ fillHeaders, getDecodeSplitHeader, } = window.__bootstrap.headers; - const { HttpClientPrototype } = window.__bootstrap.fetch; + const { HttpClient } = window.__bootstrap.fetch; const abortSignal = window.__bootstrap.abortSignal; const { ArrayPrototypeMap, @@ -36,7 +36,6 @@ MapPrototypeGet, MapPrototypeSet, ObjectKeys, - ObjectPrototypeIsPrototypeOf, RegExpPrototypeTest, Symbol, SymbolFor, @@ -242,9 +241,7 @@ const parsedURL = new URL(input, baseURL); request = newInnerRequest("GET", parsedURL.href, [], null, true); } else { // 6. - if (!ObjectPrototypeIsPrototypeOf(RequestPrototype, input)) { - throw new TypeError("Unreachable"); - } + if (!(input instanceof Request)) throw new TypeError("Unreachable"); request = input[_request]; signal = input[_signal]; } @@ -271,10 +268,7 @@ // NOTE: non standard extension. This handles Deno.HttpClient parameter if (init.client !== undefined) { - if ( - init.client !== null && - !ObjectPrototypeIsPrototypeOf(HttpClientPrototype, init.client) - ) { + if (init.client !== null && !(init.client instanceof HttpClient)) { throw webidl.makeException( TypeError, "`client` must be a Deno.HttpClient", @@ -318,7 +312,7 @@ // 33. let inputBody = null; - if (ObjectPrototypeIsPrototypeOf(RequestPrototype, input)) { + if (input instanceof Request) { inputBody = input[_body]; } @@ -362,32 +356,32 @@ } get method() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].method; } get url() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].url(); } get headers() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_headers]; } get redirect() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_request].redirectMode; } get signal() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); return this[_signal]; } clone() { - webidl.assertBranded(this, RequestPrototype); + webidl.assertBranded(this, Request); if (this[_body] && this[_body].unusable()) { throw new TypeError("Body is unusable."); } @@ -404,7 +398,7 @@ [SymbolFor("Deno.customInspect")](inspect) { return inspect(consoleInternal.createFilteredInspectProxy({ object: this, - evaluate: ObjectPrototypeIsPrototypeOf(RequestPrototype, this), + evaluate: this instanceof Request, keys: [ "bodyUsed", "headers", @@ -416,18 +410,18 @@ } } + mixinBody(Request, _body, _mimeType); + webidl.configurePrototype(Request); - const RequestPrototype = Request.prototype; - mixinBody(RequestPrototype, _body, _mimeType); webidl.converters["Request"] = webidl.createInterfaceConverter( "Request", - RequestPrototype, + Request, ); webidl.converters["RequestInfo_DOMString"] = (V, opts) => { // Union for (Request or USVString) if (typeof V == "object") { - if (ObjectPrototypeIsPrototypeOf(RequestPrototype, V)) { + if (V instanceof Request) { return webidl.converters["Request"](V, opts); } } |