Catch Security Errors in styleSheet rules (#437)

This commit is contained in:
Krzysztof Grziwok
2026-04-01 12:00:00 +08:00
committed by GitHub
parent dba421d2c5
commit 987d58ba35
2 changed files with 15 additions and 7 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
.vscode .vscode
.idea
node_modules node_modules
package-lock.json package-lock.json
# yarn.lock # yarn.lock

View File

@@ -849,16 +849,23 @@ export class Replayer {
if (d.adds) { if (d.adds) {
d.adds.forEach(({ rule, index }) => { d.adds.forEach(({ rule, index }) => {
const _index =
index === undefined
? undefined
: Math.min(index, styleSheet.rules.length);
try { try {
styleSheet.insertRule(rule, _index); const _index =
index === undefined
? undefined
: Math.min(index, styleSheet.rules.length);
try {
styleSheet.insertRule(rule, _index);
} catch (e) {
/**
* sometimes we may capture rules with browser prefix
* insert rule with prefixs in other browsers may cause Error
*/
}
} catch (e) { } catch (e) {
/** /**
* sometimes we may capture rules with browser prefix * accessing styleSheet rules may cause SecurityError
* insert rule with prefixs in other browsers may cause Error * for specific access control settings
*/ */
} }
}); });