Remove recursiveness from directionality search

This commit is contained in:
Dmitry Kolupaev 2020-02-16 19:14:40 +03:00
parent 7e2107b1a5
commit edb940e613
4 changed files with 35 additions and 26 deletions

View file

@ -543,8 +543,11 @@ impl Element {
// https://html.spec.whatwg.org/multipage/#the-directionality
pub fn directionality(&self) -> String {
if let Some(html_element) = self.downcast::<HTMLElement>() {
html_element.directionality()
if let Some(directionality) = self
.downcast::<HTMLElement>()
.and_then(|html_element| html_element.directionality())
{
directionality
} else {
let node = self.upcast::<Node>();
node.parent_directionality()