Simplify node#parent_directionality

This commit is contained in:
Dmitry Kolupaev 2020-02-16 00:58:27 +03:00
parent 7d6d1c09cb
commit 7e2107b1a5
3 changed files with 6 additions and 9 deletions

View file

@ -788,7 +788,10 @@ impl HTMLElement {
}
if element_direction == "auto" {
if let Some(directionality) = self.downcast::<HTMLInputElement>().and_then(|input| input.auto_directionality()) {
if let Some(directionality) = self
.downcast::<HTMLInputElement>()
.and_then(|input| input.auto_directionality())
{
return directionality;
}

View file

@ -434,19 +434,13 @@ impl Node {
}
pub fn parent_directionality(&self) -> String {
println!("Node#parent_directionality");
match self.GetParentNode() {
Some(parent) => {
if parent.is::<Document>() {
return "ltr".to_owned();
}
println!("Node#parent_directionality Some(Parent)");
return if let Some(parent_html) = parent.downcast::<Element>() {
if let Some(parent_html) = parent.downcast::<Element>() {
parent_html.directionality()
} else {
parent.parent_directionality()
};
}
},
None => "ltr".to_owned(),
}