From eb990efcce1e5390e4ed76b858c05c6f9b3b6c11 Mon Sep 17 00:00:00 2001 From: Lino Le Van <11367844+lino-levan@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:28:33 -0700 Subject: [PATCH] feat(ext/url): URLSearchParams.size (#17884) --- ext/url/00_url.js | 5 +++++ ext/url/lib.deno_url.d.ts | 8 ++++++++ tools/wpt/expectation.json | 1 + 3 files changed, 14 insertions(+) diff --git a/ext/url/00_url.js b/ext/url/00_url.js index 422a239304..c288225e3e 100644 --- a/ext/url/00_url.js +++ b/ext/url/00_url.js @@ -302,6 +302,11 @@ class URLSearchParams { webidl.assertBranded(this, URLSearchParamsPrototype); return ops.op_url_stringify_search_params(this[_list]); } + + get size() { + webidl.assertBranded(this, URLSearchParamsPrototype); + return this[_list].length; + } } webidl.mixinPairIterable("URLSearchParams", URLSearchParams, _list, 0, 1); diff --git a/ext/url/lib.deno_url.d.ts b/ext/url/lib.deno_url.d.ts index 329f5bf551..0181c6fb34 100644 --- a/ext/url/lib.deno_url.d.ts +++ b/ext/url/lib.deno_url.d.ts @@ -150,6 +150,14 @@ declare class URLSearchParams { * ``` */ toString(): string; + + /** Contains the number of search parameters + * + * ```ts + * searchParams.size + * ``` + */ + size: number; } /** The URL interface represents an object providing static methods used for diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json index 52011ec1e4..885354a45d 100644 --- a/tools/wpt/expectation.json +++ b/tools/wpt/expectation.json @@ -2090,6 +2090,7 @@ "urlsearchparams-has.any.worker.html": true, "urlsearchparams-set.any.html": true, "urlsearchparams-set.any.worker.html": true, + "urlsearchparams-size.any.html": true, "urlsearchparams-sort.any.html": true, "urlsearchparams-sort.any.worker.html": true, "urlsearchparams-stringifier.any.html": true,