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
This commit is contained in:
Emilio Cobos Álvarez 2017-12-18 12:53:38 +01:00
parent ce1d8cd232
commit 76257ae4df
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -668,6 +668,17 @@ impl<E: TElement> StyleSharingCache<E> {
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;