Skip to content

Commit

Permalink
Add a try/catch to provide some robustness in case `document.implemen…
Browse files Browse the repository at this point in the history
…tation.createHTMLDocument` isn't available
  • Loading branch information
eoghanmurray committed Apr 12, 2023
1 parent cc5e987 commit 1de271e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,14 @@ export default class MutationBuffer {
if (isIgnored(m.target, this.mirror)) {
return;
}
const unattachedDoc = document.implementation.createHTMLDocument(); // avoid upsetting original document from a Content Security point of view
let unattachedDoc;
try {
// avoid upsetting original document from a Content Security point of view
unattachedDoc = document.implementation.createHTMLDocument();
} catch (e) {
// fallback to more direct method
unattachedDoc = this.doc;
}
switch (m.type) {
case 'characterData': {
const value = m.target.textContent;
Expand Down

0 comments on commit 1de271e

Please sign in to comment.