mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 14:58:37 +09:00
Issue #1593 - Follow-up: Fix :host matching from inside the shadow tree
Previously, we'd match :host despite the element having a different shadow root from the one that we currently have. Also, there's a test where :host should be blocked from matching if it is a descendant of an explicit universal selector.
This commit is contained in:
parent
fbb5f73459
commit
7374ca6716
1 changed files with 19 additions and 1 deletions
|
|
@ -1965,17 +1965,35 @@ static bool SelectorMatches(Element* aElement,
|
|||
|
||||
case CSSPseudoClassType::host:
|
||||
{
|
||||
ShadowRoot* shadow = aElement->GetShadowRoot();
|
||||
// In order to match :host, the element must be a shadow root host,
|
||||
// we must be matching only against host pseudo selectors, and the
|
||||
// selector's context must be the shadow root (the selector must be
|
||||
// featureless, the left-most selector, and be in a shadow root
|
||||
// style).
|
||||
if (!aElement->GetShadowRoot() ||
|
||||
if (!shadow ||
|
||||
aSelector->HasFeatureSelectors() ||
|
||||
aSelectorFlags & SelectorMatchesFlags::IS_HOST_INACCESSIBLE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We're matching :host from inside the shadow root.
|
||||
if (!aTreeMatchContext.mOnlyMatchHostPseudo) {
|
||||
// Check if the element has the same shadow root.
|
||||
if (aTreeMatchContext.mScopedRoot) {
|
||||
if (shadow !=
|
||||
aTreeMatchContext.mScopedRoot->GetShadowRoot()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// We were called elsewhere.
|
||||
}
|
||||
|
||||
// Reject if the next selector is an explicit universal selector.
|
||||
if (aSelector->mNext && aSelector->mNext->mExplicitUniversal) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The :host selector may also be be functional, with a compound
|
||||
// selector. If this is the case, then also ensure that the host
|
||||
// element matches against the compound selector.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue