JSFiddle - React, Tailwind, and code Playground
HTML
<broken-positioning></broken-positioning>
<button>button outside the shadow tree</button>
CSS
button {
position: fixed;
left: calc(100vw - 200px);
}
JavaScript
const hostStyles = () => {
const stylesTag = document.createElement("style")
stylesTag.innerHTML = `
button {
position: fixed;
left: calc(100vw - 200px);
}
`
return stylesTag
}
class Test extends HTMLElement {
connectedCallback() {
this.root = this.attachShadow({ mode: "open" })
this.root.innerHTML = `<div>Shadow element <button>button inside the shadow tree</button> </div>`;
this.root.appendChild(hostStyles())
}
}
customElements.define("broken-positioning", Test)