Prechádzať zdrojové kódy

LibWeb: Add the URL::searchParams attribute

Idan Horowitz 3 rokov pred
rodič
commit
fe32c9c3bd

+ 1 - 0
Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator.cpp

@@ -1481,6 +1481,7 @@ void generate_prototype_implementation(IDL::Interface const& interface)
 #include <LibWeb/Bindings/RangeWrapper.h>
 #include <LibWeb/Bindings/StyleSheetListWrapper.h>
 #include <LibWeb/Bindings/TextWrapper.h>
+#include <LibWeb/Bindings/URLSearchParamsWrapper.h>
 #include <LibWeb/Bindings/WindowObject.h>
 #include <LibWeb/DOM/Element.h>
 #include <LibWeb/DOM/EventListener.h>

+ 5 - 0
Userland/Libraries/LibWeb/URL/URL.cpp

@@ -75,4 +75,9 @@ DOM::ExceptionOr<void> URL::set_href(String const& href)
     return {};
 }
 
+URLSearchParams const* URL::search_params() const
+{
+    return m_query;
+}
+
 }

+ 2 - 0
Userland/Libraries/LibWeb/URL/URL.h

@@ -31,6 +31,8 @@ public:
     String href() const;
     DOM::ExceptionOr<void> set_href(String const&);
 
+    URLSearchParams const* search_params() const;
+
     String to_json() const;
 
     void set_query(Badge<URLSearchParams>, String query) { m_url.set_query(move(query)); }

+ 1 - 1
Userland/Libraries/LibWeb/URL/URL.idl

@@ -11,7 +11,7 @@ interface URL {
     // TODO: attribute USVString port;
     // TODO: attribute USVString pathname;
     // TODO: attribute USVString search;
-    // TODO: [SameObject] readonly attribute URLSearchParams searchParams;
+    [SameObject] readonly attribute URLSearchParams searchParams;
     // TODO: attribute USVString hash;
 
     USVString toJSON();

+ 6 - 0
Userland/Libraries/LibWeb/URL/URLSearchParams.h

@@ -55,3 +55,9 @@ private:
 };
 
 }
+
+namespace Web::Bindings {
+
+URLSearchParamsWrapper* wrap(JS::GlobalObject&, URL::URLSearchParams&);
+
+}