summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCanadaHonk <oj@oojmed.com>2023-02-23 13:32:08 +0000
committerLinus Groh <mail@linusgroh.de>2023-02-28 13:24:27 +0000
commit3e2ceef8c3553ed1dc0fb528c6ea666273322e30 (patch)
treeb7c6d6578f393d5ac855cdb3869b2cb084f30cdc
parente231f72f6119926eda568cbd19c4cec684c0b77a (diff)
downloadserenity-3e2ceef8c3553ed1dc0fb528c6ea666273322e30.zip
LibWeb: Add size to URLSearchParams
Added new size parameter to URLSearchParams. Spec: https://url.spec.whatwg.org/#dom-urlsearchparams-size Co-Authored-By: Linus Groh <mail@linusgroh.de>
-rw-r--r--Userland/Libraries/LibWeb/URL/URLSearchParams.cpp7
-rw-r--r--Userland/Libraries/LibWeb/URL/URLSearchParams.h1
-rw-r--r--Userland/Libraries/LibWeb/URL/URLSearchParams.idl2
3 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
index 14ef8d01d6..73ab3dc379 100644
--- a/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
+++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.cpp
@@ -149,6 +149,13 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<URLSearchParams>> URLSearchParams::construc
return URLSearchParams::create(realm, url_decode(stripped_init));
}
+// https://url.spec.whatwg.org/#dom-urlsearchparams-size
+size_t URLSearchParams::size() const
+{
+ // The size getter steps are to return this’s list’s size.
+ return m_list.size();
+}
+
void URLSearchParams::append(DeprecatedString const& name, DeprecatedString const& value)
{
// 1. Append a new name-value pair whose name is name and value is value, to list.
diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.h b/Userland/Libraries/LibWeb/URL/URLSearchParams.h
index 78b50826a5..bdc7755413 100644
--- a/Userland/Libraries/LibWeb/URL/URLSearchParams.h
+++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.h
@@ -28,6 +28,7 @@ public:
virtual ~URLSearchParams() override;
+ size_t size() const;
void append(DeprecatedString const& name, DeprecatedString const& value);
void delete_(DeprecatedString const& name);
DeprecatedString get(DeprecatedString const& name);
diff --git a/Userland/Libraries/LibWeb/URL/URLSearchParams.idl b/Userland/Libraries/LibWeb/URL/URLSearchParams.idl
index 2ee96906b1..6269743ad8 100644
--- a/Userland/Libraries/LibWeb/URL/URLSearchParams.idl
+++ b/Userland/Libraries/LibWeb/URL/URLSearchParams.idl
@@ -4,6 +4,8 @@ interface URLSearchParams {
constructor(optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init = "");
+ readonly attribute unsigned long size;
+
undefined append(USVString name, USVString value);
undefined delete(USVString name);
USVString? get(USVString name);