Do not crash even on css rule insertion failure

This commit is contained in:
tusooa 2026-07-29 14:12:56 -04:00
commit ed958736b3
No known key found for this signature in database
GPG key ID: 42AEC43D48433C51
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1 @@
Do not crash even on css rule insertion failure

View file

@ -59,7 +59,13 @@ export const adoptStyleSheets = throttle(() => {
.sort((a, b) => a.priority - b.priority) .sort((a, b) => a.priority - b.priority)
.map((sheet) => { .map((sheet) => {
const css = new CSSStyleSheet() const css = new CSSStyleSheet()
sheet.rules.forEach((r) => css.insertRule(r)) sheet.rules.forEach((r) => {
try {
css.insertRule(r)
} catch (e) {
console.warn('Error inserting rule:', e, r)
}
})
return css return css
}) })
} else { } else {