From 76257ae4df6e658288b8845fbd70b9fb0f5fd64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 18 Dec 2017 12:53:38 +0100 Subject: [PATCH] style: Add a necessary check for style sharing between ::slotted() nodes. If two elements are assigned to different slots, even within the same shadow root, they could match different rules, due to the slot being assigned to yet another slot in another shadow root. MozReview-Commit-ID: CfZJCVxIQzM --- components/style/sharing/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index 6a2e16a1177..fd25c1b72cc 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -668,6 +668,17 @@ impl StyleSharingCache { return None; } + // If the elements are not assigned to the same slot they could match + // different ::slotted() rules in the slot scope. + // + // If two elements are assigned to different slots, even within the same + // shadow root, they could match different rules, due to the slot being + // assigned to yet another slot in another shadow root. + if target.element.assigned_slot() != candidate.element.assigned_slot() { + trace!("Miss: Different style scopes"); + return None; + } + if *target.get_local_name() != *candidate.element.get_local_name() { trace!("Miss: Local Name"); return None;