mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
We were handling removing the style sheet from the shadow root, but not appending to it. Fixing this also revealed a bug that a removed link element would always try to remove from the document's list, as the root is no longer the shadow root it's in. The fix is to use the passed in old root to remove the style sheet from. Fixes the cookie banner on https://nos.nl/
41 lines
1.4 KiB
HTML
41 lines
1.4 KiB
HTML
<!DOCTYPE html>
|
|
<div id="shadowhost"></div>
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest((done) => {
|
|
const shadowHost = document.getElementById("shadowhost");
|
|
const shadowRoot = shadowHost.attachShadow({ mode: "closed" });
|
|
|
|
const linkEl = document.createElement("link");
|
|
linkEl.href = "../valid.css";
|
|
linkEl.rel = "stylesheet";
|
|
|
|
const printSheets = () => {
|
|
println(`is linkEl.sheet null? ${linkEl.sheet === null}`)
|
|
println(`- document stylesheets (length = ${document.styleSheets.length})`);
|
|
for (const sheet of document.styleSheets) {
|
|
println(`-- document stylesheet linkEl.sheet === sheet: ${linkEl.sheet === sheet}`);
|
|
}
|
|
println(`- shadow root stylesheets (length = ${shadowRoot.styleSheets.length})`);
|
|
for (const sheet of shadowRoot.styleSheets) {
|
|
println(`-- shadow root linkEl.sheet === sheet: ${linkEl.sheet === sheet}`);
|
|
}
|
|
};
|
|
|
|
println("== before appending");
|
|
printSheets();
|
|
|
|
linkEl.addEventListener("load", () => {
|
|
println("== link loaded");
|
|
printSheets();
|
|
|
|
linkEl.remove();
|
|
println("== link removed");
|
|
printSheets();
|
|
done();
|
|
}, { once: true });
|
|
|
|
shadowRoot.appendChild(linkEl);
|
|
});
|
|
</script>
|