Skip to content

Commit 1c065e8

Browse files
committed
Fix for rrweb-io#816 - avoid triggering a CSP (content security policy) error with .setAttribute('style')
1 parent 41cc822 commit 1c065e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/rrweb/src/record/mutation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ export default class MutationBuffer {
462462
if (isIgnored(m.target, this.mirror)) {
463463
return;
464464
}
465+
const unattachedDoc = new Document(); // avoid upsetting original document from a Content Security point of view
465466
switch (m.type) {
466467
case 'characterData': {
467468
const value = m.target.textContent;
@@ -543,7 +544,7 @@ export default class MutationBuffer {
543544
}
544545

545546
if (attributeName === 'style') {
546-
const old = this.doc.createElement('span');
547+
const old = unattachedDoc.createElement('span');
547548
if (m.oldValue) {
548549
old.setAttribute('style', m.oldValue);
549550
}

0 commit comments

Comments
 (0)