diff options
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 4 | ||||
-rw-r--r-- | components/script/dom/urlsearchparams.rs | 11 | ||||
-rw-r--r-- | components/script/dom/webidls/URLSearchParams.webidl | 3 |
3 files changed, 10 insertions, 8 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 01b7fc698ba..5a6c453e0ce 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -732,6 +732,10 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, default = "%s::Boolean(%s)" % ( union_native_type(type), "true" if defaultValue.value else "false") + elif tag is IDLType.Tags.usvstring: + default = '%s::USVString(USVString("%s".to_owned()))' % ( + union_native_type(type), + defaultValue.value) else: raise("We don't currently support default values that aren't null, boolean or default dictionary") elif dictionaries: diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index 57c86898482..3664d30d1f7 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -47,12 +47,12 @@ impl URLSearchParams { // https://url.spec.whatwg.org/#dom-urlsearchparams-urlsearchparams pub fn Constructor( global: &GlobalScope, - init: Option<USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString>, + init: USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString, ) -> Fallible<DomRoot<URLSearchParams>> { // Step 1. let query = URLSearchParams::new(global, None); match init { - Some(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringSequenceSequence(init)) => { + USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringSequenceSequence(init) => { // Step 2. // Step 2-1. @@ -64,12 +64,12 @@ impl URLSearchParams { *query.list.borrow_mut() = init.iter().map(|pair| (pair[0].to_string(), pair[1].to_string())).collect::<Vec<_>>(); }, - Some(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringUSVStringRecord(init)) => { + USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVStringUSVStringRecord(init) => { // Step 3. *query.list.borrow_mut() = (*init).iter().map(|(name, value)| (name.to_string(), value.to_string())).collect::<Vec<_>>(); }, - Some(USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVString(init)) => { + USVStringSequenceSequenceOrUSVStringUSVStringRecordOrUSVString::USVString(init) => { // Step 4. let init_bytes = match init.0.chars().next() { Some(first_char) if first_char == '?' => { @@ -82,8 +82,7 @@ impl URLSearchParams { *query.list.borrow_mut() = form_urlencoded::parse(init_bytes).into_owned().collect(); - }, - None => {}, + } } // Step 5. diff --git a/components/script/dom/webidls/URLSearchParams.webidl b/components/script/dom/webidls/URLSearchParams.webidl index 70845900003..33ba9253624 100644 --- a/components/script/dom/webidls/URLSearchParams.webidl +++ b/components/script/dom/webidls/URLSearchParams.webidl @@ -8,8 +8,7 @@ [Exposed=(Window,Worker)] interface URLSearchParams { - [Throws] constructor( - optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init); + [Throws] constructor(optional (sequence<sequence<USVString>> or record<USVString, USVString> or USVString) init = ""); void append(USVString name, USVString value); void delete(USVString name); USVString? get(USVString name); |