-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Descendant combinator is incorrectly applied to elements inside a shadow tree #40896
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-content/cssInteracting with CSS from web content (parsing, serializing, introspection)Interacting with CSS from web content (parsing, serializing, introspection)C-has-manual-testcase
Description
Describe the bug:
Descendant combinator shouldn't apply to an element if the element is inside a shadow tree and the matching ancestor is outside the shadow tree.
Servo can mainly handle this case, but fail if bring <style> into the shadow tree.
To Reproduce:
Test case:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Shadow DOM Style Test</title>
</head>
<body>
<div class="parent">
<common-cart id="hostElement"></common-cart>
</div>
<script>
const hostElement = document.getElementById('hostElement');
const shadowRoot = hostElement.attachShadow({mode: 'open'});
shadowRoot.innerHTML = `
<div class="child">
<style>
.parent .child {
border: 5px solid red;
background-color: yellow;
}
</style>
This element is inside the Shadow DOM. <br>
It should NOT have a red border and yellow background from descendant combinator style.
</div>
`;
</script>
</body>
</html>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-content/cssInteracting with CSS from web content (parsing, serializing, introspection)Interacting with CSS from web content (parsing, serializing, introspection)C-has-manual-testcase

