mirror of
https://github.com/MercuryWorkshop/dreamlandjs.git
synced 2025-05-15 07:10:00 -04:00
fix: non-scoped css rules, scoped media rules, falsy attributes
This commit is contained in:
parent
bd94e92985
commit
f9cc927c60
3 changed files with 19 additions and 7 deletions
15
src/css.js
15
src/css.js
|
@ -96,7 +96,7 @@ export function genCss(uid, str, scoped) {
|
|||
|
||||
let extstr = ''
|
||||
for (const rule of styleElement.sheet.cssRules) {
|
||||
if (!rule.selectorText) {
|
||||
if (!rule.selectorText && !rule.media) {
|
||||
extstr += rule.cssText
|
||||
} else if (rule.selectorText?.startsWith(':')) {
|
||||
rule.selectorText = `.${uid}${rule.selectorText}`
|
||||
|
@ -109,7 +109,18 @@ export function genCss(uid, str, scoped) {
|
|||
styleElement.textContent = `.${uid} {${selfstr}} @scope (.${uid}) to (:not(.${uid}).${cssBoundary} *) { ${newstr} } ${extstr}`
|
||||
} else {
|
||||
for (const rule of styleElement.sheet.cssRules) {
|
||||
rule.selectorText = `.${uid} ${rule.selectorText}`
|
||||
if (rule.selectorText)
|
||||
rule.selectorText = rule.selectorText
|
||||
.split(',')
|
||||
.map((x) => {
|
||||
x = x.trim()
|
||||
if (x[0] === ':') {
|
||||
return `.${uid}${x}`
|
||||
} else {
|
||||
return `.${uid} ${x}`
|
||||
}
|
||||
})
|
||||
.join(', ')
|
||||
newstr += rule.cssText
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue