Skip to content

_this.doc maybe undefined? #1203

@RedLemonPie

Description

@RedLemonPie

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/rrweb/lib/rrweb.js b/node_modules/rrweb/lib/rrweb.js
index a6992d6..02610cd 100644
--- a/node_modules/rrweb/lib/rrweb.js
+++ b/node_modules/rrweb/lib/rrweb.js
@@ -2426,8 +2426,16 @@ var MutationBuffer = (function () {
                     rootShadowHost =
                         ((_e = (_d = rootShadowHost === null || rootShadowHost === void 0 ? void 0 : rootShadowHost.getRootNode) === null || _d === void 0 ? void 0 : _d.call(rootShadowHost)) === null || _e === void 0 ? void 0 : _e.host) ||
                             null;
-                var notInDoc = !_this.doc.contains(n) &&
-                    (rootShadowHost === null || !_this.doc.contains(rootShadowHost));
+                try {
+                    if(!_this.doc || !_this.doc.contains){
+                        var notInDoc = true
+                    }else {
+                        var notInDoc = !_this.doc.contains(n) && (rootShadowHost === null || !_this.doc.contains(rootShadowHost));
+                    }
+                } catch (error) {
+                    console.log('rrweb',error)
+                    var notInDoc = true
+                }
                 if (!n.parentNode || notInDoc) {
                     return;
                 }

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions