rrweb
rrweb copied to clipboard
[Bug]: snapshot error for Document made via DomParser
Preflight Checklist
- [X] I have searched the issue tracker for a bug report that matches the one I want to file, without success.
What package is this bug report for?
rrweb-snapshot
Version
v2.0.0-alpha.17
Expected Behavior
v2.0.0-alpha.17 should work like previous alpha versions when calling snapshot on an html document. v2.0.0-alpha.16 works fine.
Actual Behavior
My setup consists of passing custom html string that is parsed via DomParser and then fed into snapshot e.g. we should this playwright class method that previously working on older versions.
export class ReplayerPage {
constructor(public readonly page: Page) {
this.page = page;
}
generateHtmlSnapshot = (html: string): ReturnType<typeof snapshot> => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, 'text/xml');
return snapshot(htmlDoc);
};
Playwright 1.48.0 outputs an error:
TypeError: Cannot read properties of undefined (reading 'prototype')
at fixtures/replayerPage.ts:26
24 | const parser = new DOMParser();
25 | const htmlDoc = parser.parseFromString(html, 'text/xml');
> 26 | return snapshot(htmlDoc);
| ^
27 | };
28 |
29 | convertSnapshotToReplayBlob = ({
at getUntaintedPrototype (/.../node_modules/utils/dist/utils.js:18:39)
at getUntaintedAccessor (/.../node_modules/utils/dist/utils.js:66:30)
at Object.parentElement (/.../node_modules/utils/dist/utils.js:95:10)
at needMaskingText (/.../node_modules/rrweb-snapshot/src/snapshot.ts:278:18)
at serializeNodeWithId (/.../node_modules/rrweb-snapshot/src/snapshot.ts:972:17)
at snapshot (/.../node_modules/rrweb-snapshot/src/snapshot.ts:1308:10
...
Steps to Reproduce
Create a document via DomParser that parses an html string and feed to snapshot.
Testcase Gist URL
No response
Additional Information
No response