Add support for replaying StyleSheetRule events (#178)

This commit is contained in:
David Cramer
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 3a0e829884
commit 704f6d4a4f

View File

@@ -608,6 +608,28 @@ export class Replayer {
}
break;
}
case IncrementalSource.StyleSheetRule: {
const target = mirror.getNode(d.id);
if (!target) {
return this.debugNodeNotFound(d, d.id);
}
const styleEl = (target as Node) as HTMLStyleElement;
const styleSheet = <CSSStyleSheet>styleEl.sheet;
if (d.adds) {
d.adds.forEach(({ rule, index }) => {
styleSheet.insertRule(rule, index);
});
}
if (d.removes) {
d.removes.forEach(({ index }) => {
styleSheet.deleteRule(index);
});
}
break;
}
default:
}
}