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

[Bug]: v2.0.0-alpha.17 snapshot error for Document made via DomParser #1584

Open
1 task done
fadi-george opened this issue Oct 19, 2024 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@fadi-george
Copy link

Preflight Checklist

  • 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

@fadi-george fadi-george added the bug Something isn't working label Oct 19, 2024
@fadi-george fadi-george changed the title [Bug]: snapshot error for Document made via DomParser [Bug]: v2.0.0-alpha.17 snapshot error for Document made via DomParser Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant