fix: catch access stylesheet error

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-09-22 15:45:52 +08:00
parent 539f3bc599
commit bbc2bef800
@@ -155,13 +155,16 @@ function getLinkedStaticStyleSheets() {
const hasCache = cacheCssTextMap[sheet.href]
if (!hasCache) {
if (!sheet.href) continue
const rules = sheet.cssRules || sheet.rules
let cssText = ""
for (const rule of rules) {
cssText += rule.cssText
try {
const rules = sheet.cssRules || sheet.rules
let cssText = ""
for (const rule of rules) {
cssText += rule.cssText
}
cacheCssTextMap[sheet.href] = cssText
} catch (err) {
console.error("Failed to get cssText for", sheet.href, err)
}
cacheCssTextMap[sheet.href] = cssText
}
cssArray.push({