diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-10-18 04:02:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-18 04:02:13 -0400 |
commit | 32eb858a6a0534d8acdd5184a50a22d90c18b2a8 (patch) | |
tree | 663535559aa69999a1c617f2ef963c8781ae2510 | |
parent | 578d9a7fb9beb7c035be589f2d01b56462964829 (diff) | |
parent | e905a4606a089055be0f87afb62c1f4ccf2961c3 (diff) | |
download | servo-32eb858a6a0534d8acdd5184a50a22d90c18b2a8.tar.gz servo-32eb858a6a0534d8acdd5184a50a22d90c18b2a8.zip |
Auto merge of #24469 - saschanaz:urp-default, r=Manishearth
Support USVString as default value of a union argument
<!-- Please describe your changes on the following line: -->
I don't expect this fixes any test though...
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22543
<!-- Either: -->
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
-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 c80e8a0697b..17ec39913d6 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); |