Skip to content

Commit

Permalink
fix: catch access stylesheet error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Sep 20, 2024
1 parent 32a55ec commit 16a6231
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions apps/renderer/src/components/common/ShadowDOM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,25 @@ function getLinkedStaticStyleSheets() {
if (!sheet) continue
if (!sheet.href) continue
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 {
if (!hasCache) {
if (!sheet.href) continue
const rules = sheet.cssRules || sheet.rules
let cssText = ""
for (const rule of rules) {
cssText += rule.cssText
}

cacheCssTextMap[sheet.href] = cssText
cssArray.push({
cssText: cacheCssTextMap[sheet.href],
ref: $link,
})
}

cacheCssTextMap[sheet.href] = cssText
} catch (e) {
console.info("Parse css error", sheet.href)
console.error(e)
}

cssArray.push({
cssText: cacheCssTextMap[sheet.href],
ref: $link,
})
}

return cssArray
Expand Down

0 comments on commit 16a6231

Please sign in to comment.