Open mantou132 opened 4 years ago
This was discussed and resolved here: https://github.com/WICG/construct-stylesheets/issues/93#issuecomment-577713131
As of right now, constructed always go after other author sheets.
use @layer can solve the problem:
const sheet = new CSSStyleSheet();
sheet.replaceSync(`
@layer {
h1 {
color: blue;
}
}
`);
document.adoptedStyleSheets = [sheet];
document.body.innerHTML = `
<style>
h1 {
color: red;
}
</style>
<h1>title</h1>
`;
construct stylesheet overrides
<style>
.but sometimes I don't want to override the style of
<style>
<link>
in the code, I just want to construct stylesheet to work like a browser stylesheet. // case:<gem-frame>
is there a way to determine the priority of constructing stylesheet?