From 519ed44ebb4bab71c6b80f7c1ef432354654da8c Mon Sep 17 00:00:00 2001 From: Phosra Date: Thu, 28 Jul 2022 04:18:17 -0700 Subject: [PATCH] fix(ext/fetch): resolve TODOs about WebIDL conversions in body init (#15312) --- ext/fetch/22_body.js | 6 ++---- ext/url/00_url.js | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index f33097033f..10ddb7603d 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -452,15 +452,13 @@ webidl.converters["BodyInit_DOMString"] = (V, opts) => { // Union for (ReadableStream or Blob or ArrayBufferView or ArrayBuffer or FormData or URLSearchParams or USVString) if (ObjectPrototypeIsPrototypeOf(ReadableStreamPrototype, V)) { - // TODO(lucacasonato): ReadableStream is not branded - return V; + return webidl.converters["ReadableStream"](V, opts); } else if (ObjectPrototypeIsPrototypeOf(BlobPrototype, V)) { return webidl.converters["Blob"](V, opts); } else if (ObjectPrototypeIsPrototypeOf(FormDataPrototype, V)) { return webidl.converters["FormData"](V, opts); } else if (ObjectPrototypeIsPrototypeOf(URLSearchParamsPrototype, V)) { - // TODO(lucacasonato): URLSearchParams is not branded - return V; + return webidl.converters["URLSearchParams"](V, opts); } if (typeof V === "object") { if ( diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 4e6c7ac47f..06630a2d01 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -300,6 +300,11 @@ webidl.configurePrototype(URLSearchParams); const URLSearchParamsPrototype = URLSearchParams.prototype; + webidl.converters["URLSearchParams"] = webidl.createInterfaceConverter( + "URLSearchParams", + URLSearchParamsPrototype, + ); + const _url = Symbol("url"); class URL {