Skip to content

Commit 92febda

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

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
@@ -426,6 +426,7 @@ export default class MutationBuffer {
426426
if (isIgnored(m.target)) {
427427
return;
428428
}
429+
const unattachedDoc = new Document(); // avoid upsetting original document from a Content Security point of view
429430
switch (m.type) {
430431
case 'characterData': {
431432
const value = m.target.textContent;
@@ -472,7 +473,7 @@ export default class MutationBuffer {
472473
this.attributes.push(item);
473474
}
474475
if (m.attributeName === 'style') {
475-
const old = this.doc.createElement('span');
476+
const old = unattachedDoc.createElement('span');
476477
if (m.oldValue) {
477478
old.setAttribute('style', m.oldValue);
478479
}

0 commit comments

Comments
 (0)