diff --git a/components/style/traversal.rs b/components/style/traversal.rs index 004c2485afd..707f2c2783c 100644 --- a/components/style/traversal.rs +++ b/components/style/traversal.rs @@ -326,14 +326,21 @@ pub trait DomTraversal : Sync { // the element if the element has animation only dirty // descendants bit, animation-only restyle hint or recascade. if traversal_flags.for_animation_only() { - if el.has_animation_only_dirty_descendants() { - return true; - } - + // Skip elements that have no style data since animation-only + // restyle is not necessary for the elements. let data = match el.borrow_data() { Some(d) => d, None => return false, }; + + if !data.has_styles() { + return false; + } + + if el.has_animation_only_dirty_descendants() { + return true; + } + return data.restyle.hint.has_animation_hint() || data.restyle.hint.has_recascade_self(); }