Skip to content

Commit

Permalink
apply review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
YunFeng0817 committed Jul 3, 2024
1 parent 71245d7 commit d1fba35
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .changeset/cuddly-bikes-fail.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"rrweb": patch
---

fix: duplicate textContent for style element cause incremental style mutation invalid
fix: duplicate textContent for style elements cause incremental style mutations to be invalid
2 changes: 1 addition & 1 deletion packages/rrweb/src/replay/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ export class Replayer {
) {
// https://github.com/rrweb-io/rrweb/pull/1417
/**
* If both _cssText and textContent are present for a style element due to some exist bugs, the element will have two child text nodes.
* If both _cssText and textContent are present for a style element due to some existing bugs, the element will have two child text nodes.
* We need to remove the textNode created by _cssText to avoid issue.
*/
for (const cssText of childNodeArray as (Node & RRNode)[]) {
Expand Down
7 changes: 6 additions & 1 deletion packages/rrweb/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,11 @@ describe('record integration tests', function (this: ISuite) {
document.head.appendChild(incrementalStyle);
incrementalStyle.sheet!.insertRule(`#two { color: ${OldColor}; }`, 0);

await new Promise((resolve) => setTimeout(resolve, 0));
await new Promise((resolve) =>
requestAnimationFrame(() => {
requestAnimationFrame(resolve);
}),
);

// Change the color of the #one div element to yellow as an incremental style mutation
const styleElement = document.querySelector('style')!;
Expand All @@ -1304,6 +1308,7 @@ describe('record integration tests', function (this: ISuite) {
OldColor,
NewColor,
);
await waitForRAF(page);

const snapshots = (await page.evaluate(
'window.snapshots',
Expand Down

0 comments on commit d1fba35

Please sign in to comment.