diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/fetch/22_body.js | 11 | ||||
-rw-r--r-- | ext/fetch/23_request.js | 2 | ||||
-rw-r--r-- | ext/fetch/23_response.js | 2 |
3 files changed, 9 insertions, 6 deletions
diff --git a/ext/fetch/22_body.js b/ext/fetch/22_body.js index 49da149c2..acbef4ec4 100644 --- a/ext/fetch/22_body.js +++ b/ext/fetch/22_body.js @@ -372,7 +372,7 @@ return { body, contentType }; } - webidl.converters["BodyInit"] = (V, opts) => { + webidl.converters["BodyInit_DOMString"] = (V, opts) => { // Union for (ReadableStream or Blob or ArrayBufferView or ArrayBuffer or FormData or URLSearchParams or USVString) if (V instanceof ReadableStream) { // TODO(lucacasonato): ReadableStream is not branded @@ -393,10 +393,13 @@ return webidl.converters["ArrayBufferView"](V, opts); } } - return webidl.converters["USVString"](V, opts); + // BodyInit conversion is passed to extractBody(), which calls core.encode(). + // core.encode() will UTF-8 encode strings with replacement, being equivalent to the USV normalization. + // Therefore we can convert to DOMString instead of USVString and avoid a costly redundant conversion. + return webidl.converters["DOMString"](V, opts); }; - webidl.converters["BodyInit?"] = webidl.createNullableConverter( - webidl.converters["BodyInit"], + webidl.converters["BodyInit_DOMString?"] = webidl.createNullableConverter( + webidl.converters["BodyInit_DOMString"], ); window.__bootstrap.fetchBody = { mixinBody, InnerBody, extractBody }; diff --git a/ext/fetch/23_request.js b/ext/fetch/23_request.js index 06843d60c..dfb7e2127 100644 --- a/ext/fetch/23_request.js +++ b/ext/fetch/23_request.js @@ -445,7 +445,7 @@ { key: "body", converter: webidl.createNullableConverter( - webidl.converters["BodyInit"], + webidl.converters["BodyInit_DOMString"], ), }, { key: "redirect", converter: webidl.converters["RequestRedirect"] }, diff --git a/ext/fetch/23_response.js b/ext/fetch/23_response.js index 32ce88d42..61e1de151 100644 --- a/ext/fetch/23_response.js +++ b/ext/fetch/23_response.js @@ -253,7 +253,7 @@ */ constructor(body = null, init = {}) { const prefix = "Failed to construct 'Response'"; - body = webidl.converters["BodyInit?"](body, { + body = webidl.converters["BodyInit_DOMString?"](body, { prefix, context: "Argument 1", }); |