Add support for StylesheetRule in document fragment (#293)

* add failing test

* add stylesheet to dom to manipulate the rules

* cleanup
This commit is contained in:
Justin Halsall
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 70fe32b5d2
commit 455c4d76f4
3 changed files with 129 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import {
sampleEvents as events,
sampleStyleSheetRemoveEvents as stylesheetRemoveEvents
} from './utils';
import styleSheetRuleEvents from './events/style-sheet-rule-events';
interface ISuite extends Suite {
code: string;
@@ -135,6 +136,19 @@ describe('replayer', function (this: ISuite) {
expect(currentState).to.equal('paused');
});
it('can fast forward past StyleSheetRule changes on virtual elements', async () => {
await this.page.evaluate(`events = ${JSON.stringify(styleSheetRuleEvents)}`);
const actionLength = await this.page.evaluate(`
const { Replayer } = rrweb;
const replayer = new Replayer(events);
replayer.play(1500);
replayer['timer']['actions'].length;
`);
expect(actionLength).to.equal(
styleSheetRuleEvents.filter((e) => e.timestamp - styleSheetRuleEvents[0].timestamp >= 1500).length,
);
});
it('can handle removing style elements', async () => {
await this.page.evaluate(`events = ${JSON.stringify(stylesheetRemoveEvents)}`);
const actionLength = await this.page.evaluate(`