diff options
Diffstat (limited to 'src/components/script/script_task.rs')
-rw-r--r-- | src/components/script/script_task.rs | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs index 09d9ee59aa6..e06439f912d 100644 --- a/src/components/script/script_task.rs +++ b/src/components/script/script_task.rs @@ -1148,30 +1148,27 @@ impl ScriptTask { } for node_address in node_address.iter() { - let mut node = - node::from_untrusted_node_address( - self.js_runtime.deref().ptr, *node_address).root(); - // Traverse node generations until a node that is an element is - // found. - while !node.is_element() { - match node.parent_node() { - Some(parent) => node = parent.root(), - None => break, - } - } - if node.is_element() { - node.set_hover_state(true); - - match *mouse_over_targets { - Some(ref mouse_over_targets) => { - if !target_compare { - target_compare = !mouse_over_targets.contains(&node.unrooted()); + let temp_node = + node::from_untrusted_node_address( + self.js_runtime.deref().ptr, *node_address); + + let maybe_node = temp_node.root().ancestors().find(|node| node.is_element()); + match maybe_node { + Some(mut node) => { + node.set_hover_state(true); + + match *mouse_over_targets { + Some(ref mouse_over_targets) => { + if !target_compare { + target_compare = !mouse_over_targets.contains(&node.unrooted()); + } } + None => {} } - None => {} + target_list.push(node.unrooted()); } - target_list.push(node.unrooted()); + None => {} } } match *mouse_over_targets { |