Re: [csswg-drafts] [specificity] Specifity of ::slotted() is greater than :host

In your original example, the green and the red aren't being specified on the same element, so there's no specificity issue.  Instead, you're setting the color on :host and relying on inheritance to propagate that downwards, but inheritance *always* loses to directly styling an element (which `::slotted(*)` does), no matter what selector it comes from.

In your latest example, the two declarations *are* specifying the same property on a single element - "color: green" is being specified on the host2 element via the `.host1 *` selector, and "color: red" via the `.host2` selector.  Since there are competing declarations, we rely on specificity to sort things out - in this case, both selectors have specificity [0,1,0] (because the universal selector doesn't add any specificity), and so we fall back to source ordering, so "red" wins.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2290#issuecomment-381787484 using your GitHub account

Received on Tuesday, 17 April 2018 00:04:40 UTC