fix(core): fix specificity ScopedStylesController

This commit is contained in:
Thijs Louisse 2022-03-15 23:30:13 +01:00
parent d0bcfc08e7
commit 1b5878678b

View file

@ -35,10 +35,14 @@ export class ScopedStylesController {
} }
__setupStyleTag() { __setupStyleTag() {
// Make it win from other elements on the page.
// TODO: consider adding an id here to always win, since we are simulating shadow dom
// behavior here.
const highSpecifictyScope = `${this.scopedClass}.${this.scopedClass}`;
this.__styleTag.textContent = /** @type {typeof ScopedStylesController} */ ( this.__styleTag.textContent = /** @type {typeof ScopedStylesController} */ (
this.host.constructor this.host.constructor
) )
.scopedStyles(unsafeCSS(this.scopedClass)) .scopedStyles(unsafeCSS(highSpecifictyScope))
.toString(); .toString();
this.host.insertBefore(this.__styleTag, this.host.childNodes[0]); this.host.insertBefore(this.__styleTag, this.host.childNodes[0]);
} }