Add support for replaying StyleSheetRule events (#178)

This commit is contained in:
David Cramer
2020-02-25 05:07:17 -08:00
committed by GitHub
parent 046936b3e8
commit 9b7f8d6027

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:
}
}