Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1412] fix Changes in the canvas within the Shadow DOM cannot be rec… #1413

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions packages/rrweb/src/record/observers/canvas/canvas-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
this.pendingCanvasMutations.set(target, []);
}

this.pendingCanvasMutations.get(target)!.push(mutation);

Check warning on line 101 in packages/rrweb/src/record/observers/canvas/canvas-manager.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/observers/canvas/canvas-manager.ts#L101

[@typescript-eslint/no-non-null-assertion] Forbidden non-null assertion.
};

private initCanvasFPSObserver(
Expand Down Expand Up @@ -161,11 +161,27 @@

const getCanvas = (): HTMLCanvasElement[] => {
const matchedCanvas: HTMLCanvasElement[] = [];
win.document.querySelectorAll('canvas').forEach((canvas) => {
if (!isBlocked(canvas, blockClass, blockSelector, true)) {
matchedCanvas.push(canvas);
}
});

// traverse DOM and Shadow DOM
const traverseDom = (root: Document | ShadowRoot) => {
root.querySelectorAll('canvas').forEach((canvas) => {
if (
canvas instanceof HTMLCanvasElement &&
!isBlocked(canvas, blockClass, blockSelector, true)
) {
matchedCanvas.push(canvas);
}
});

root.querySelectorAll('*').forEach((elem) => {
if (elem.shadowRoot) {
traverseDom(elem.shadowRoot);
}
});
};

traverseDom(win.document);

return matchedCanvas;
};

Expand Down Expand Up @@ -297,7 +313,7 @@
if (!valuesWithType || id === -1) return;

const values = valuesWithType.map((value) => {
const { type, ...rest } = value;

Check warning on line 316 in packages/rrweb/src/record/observers/canvas/canvas-manager.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

packages/rrweb/src/record/observers/canvas/canvas-manager.ts#L316

[@typescript-eslint/no-unused-vars] 'type' is assigned a value but never used.
return rest;
});
const { type } = valuesWithType[0];
Expand Down
Loading