Use map_or and fix manifest

This commit is contained in:
Dmitry Kolupaev 2020-02-22 13:28:22 +03:00
parent ab2aeb6d97
commit 25c5a4c045
4 changed files with 25 additions and 9 deletions

View file

@ -985,19 +985,20 @@ impl HTMLFormElement {
// An element can only have a dirname attribute if it is a textarea element
// or an input element whose type attribute is in either the Text state or the Search state
let child_element = child.downcast::<Element>().unwrap();
let input_matches = child_element
.downcast::<HTMLInputElement>()
.map(|input| {
input.input_type() == InputType::Text || input.input_type() == InputType::Search
})
.unwrap_or(false);
let input_matches =
child_element
.downcast::<HTMLInputElement>()
.map_or(false, |input| {
input.input_type() == InputType::Text ||
input.input_type() == InputType::Search
});
let textarea_matches = child_element.is::<HTMLTextAreaElement>();
let dirname = child_element.get_string_attribute(&local_name!("dirname"));
if (input_matches || textarea_matches) && !dirname.is_empty() {
let dir = DOMString::from(child_element.directionality());
data_set.push(FormDatum {
ty: DOMString::from("string"),
name: dirname.clone(),
name: dirname,
value: FormDatumValue::String(dir),
});
}