mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:27:43 +00:00
LibWeb: Add style sheets to the shadow root if applicable
If a style element belongs to a shadow tree, its CSSStyleSheet is now added to the corresponding ShadowRoot instead of the document. Co-authored-by: Simon Wanner <simon+git@skyrising.xyz>
This commit is contained in:
parent
8ce8697a66
commit
c6e69d501f
7 changed files with 45 additions and 13 deletions
18
Tests/LibWeb/Text/input/shadow-root-style-sheets.html
Normal file
18
Tests/LibWeb/Text/input/shadow-root-style-sheets.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<script src="include.js"></script>
|
||||
<my-custom-element></my-custom-element>
|
||||
<script>
|
||||
test(() => {
|
||||
class MyCustomElement extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
const shadow = this.attachShadow({ mode: 'open' });
|
||||
const style = document.createElement('style');
|
||||
shadow.appendChild(style);
|
||||
println(`shadow.styleSheets.length=${shadow.styleSheets.length}`);
|
||||
println(`document.styleSheets.length=${document.styleSheets.length}`);
|
||||
}
|
||||
}
|
||||
|
||||
customElements.define('my-custom-element', MyCustomElement);
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue