From c896ba2e1949047ce9a46f1aca27f30632911eb4 Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Wed, 29 Sep 2021 18:06:29 +0200 Subject: [PATCH] perf(webidl/DOMString): don't wrap string primitives (#12266) --- ext/webidl/00_webidl.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/webidl/00_webidl.js b/ext/webidl/00_webidl.js index 88384406a2..d5bad4f158 100644 --- a/ext/webidl/00_webidl.js +++ b/ext/webidl/00_webidl.js @@ -359,11 +359,11 @@ }; converters.DOMString = function (V, opts = {}) { - if (opts.treatNullAsEmptyString && V === null) { + if (typeof V === "string") { + return V; + } else if (V === null && opts.treatNullAsEmptyString) { return ""; - } - - if (typeof V === "symbol") { + } else if (typeof V === "symbol") { throw makeException( TypeError, "is a symbol, which cannot be converted to a string",