aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/urlsearchparams.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2023-05-28 22:43:55 -0400
committerJosh Matthews <josh@joshmatthews.net>2023-05-28 23:23:12 -0400
commitdbff26bce05d404027ef5bbfd85fb5995e4726bc (patch)
tree6ebb631eef396c2f387fe8269b0d59bde0dccae2 /components/script/dom/urlsearchparams.rs
parentd9600ff50f3c1bdd8c44e2dfc15a18416d80cb82 (diff)
downloadservo-dbff26bce05d404027ef5bbfd85fb5995e4726bc.tar.gz
servo-dbff26bce05d404027ef5bbfd85fb5995e4726bc.zip
Support arbitrary protos when wrapping DOM objects with constructors.
Diffstat (limited to 'components/script/dom/urlsearchparams.rs')
-rw-r--r--components/script/dom/urlsearchparams.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs
index 4b7e2880ef1..e4f2df9c91d 100644
--- a/components/script/dom/urlsearchparams.rs
+++ b/components/script/dom/urlsearchparams.rs
@@ -7,13 +7,14 @@ use crate::dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchPa
use crate::dom::bindings::codegen::UnionTypes::USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString;
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::iterable::Iterable;
-use crate::dom::bindings::reflector::{reflect_dom_object, Reflector};
+use crate::dom::bindings::reflector::{reflect_dom_object2, Reflector};
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::str::{DOMString, USVString};
use crate::dom::bindings::weakref::MutableWeakRef;
use crate::dom::globalscope::GlobalScope;
use crate::dom::url::URL;
use dom_struct::dom_struct;
+use js::rust::HandleObject;
use url::form_urlencoded;
// https://url.spec.whatwg.org/#interface-urlsearchparams
@@ -36,17 +37,22 @@ impl URLSearchParams {
}
pub fn new(global: &GlobalScope, url: Option<&URL>) -> DomRoot<URLSearchParams> {
- reflect_dom_object(Box::new(URLSearchParams::new_inherited(url)), global)
+ Self::new_with_proto(global, None, url)
+ }
+
+ pub fn new_with_proto(global: &GlobalScope, proto: Option<HandleObject>, url: Option<&URL>) -> DomRoot<URLSearchParams> {
+ reflect_dom_object2(Box::new(URLSearchParams::new_inherited(url)), global, proto)
}
// https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams
#[allow(non_snake_case)]
pub fn Constructor(
global: &GlobalScope,
+ proto: Option<HandleObject>,
init: USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString,
) -> Fallible<DomRoot<URLSearchParams>> {
// Step 1.
- let query = URLSearchParams::new(global, None);
+ let query = URLSearchParams::new_with_proto(global, proto, None);
match init {
USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringSequenceSequence(init) => {
// Step 2.