StyleSetter: Better handling of unsupported CSS rules (Palemoon fix)
This commit is contained in:
parent
d8802ad20d
commit
5d7aabe7ad
1 changed files with 23 additions and 6 deletions
|
|
@ -124,17 +124,34 @@ export const applyTheme = (
|
||||||
const lazyStyles = createStyleSheet(LAZY_STYLE_ID)
|
const lazyStyles = createStyleSheet(LAZY_STYLE_ID)
|
||||||
|
|
||||||
const insertRule = (styles, rule) => {
|
const insertRule = (styles, rule) => {
|
||||||
if (rule.indexOf('webkit') >= 0) {
|
try {
|
||||||
|
// Try to use modern syntax first
|
||||||
try {
|
try {
|
||||||
styles.sheet.insertRule(rule, 'index-max')
|
styles.sheet.insertRule(rule, 'index-max')
|
||||||
styles.rules.push(rule)
|
styles.rules.push(rule)
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.warn('Can\'t insert rule due to lack of support', e)
|
// Fallback for older browsers that don't support 'index-max'
|
||||||
}
|
styles.sheet.insertRule(rule, styles.sheet.cssRules.length)
|
||||||
} else {
|
|
||||||
styles.sheet.insertRule(rule, 'index-max')
|
|
||||||
styles.rules.push(rule)
|
styles.rules.push(rule)
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Can\'t insert rule due to lack of support', e, rule)
|
||||||
|
|
||||||
|
// Try to sanitize the rule for better compatibility
|
||||||
|
try {
|
||||||
|
// Remove any potentially problematic CSS features
|
||||||
|
let sanitizedRule = rule
|
||||||
|
.replace(/backdrop-filter:[^;]+;/g, '') // Remove backdrop-filter
|
||||||
|
.replace(/var\(--shadowFilter\)[^;]*;/g, '') // Remove shadowFilter references
|
||||||
|
|
||||||
|
if (sanitizedRule !== rule) {
|
||||||
|
styles.sheet.insertRule(sanitizedRule, styles.sheet.cssRules.length)
|
||||||
|
styles.rules.push(sanitizedRule)
|
||||||
|
}
|
||||||
|
} catch (e2) {
|
||||||
|
console.error('Failed to insert even sanitized rule', e2)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { lazyProcessFunc } = generateTheme(
|
const { lazyProcessFunc } = generateTheme(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue