Skip to content

Commit

Permalink
Fix for #816 - avoid triggering a CSP (content security policy) error…
Browse files Browse the repository at this point in the history
… with `.setAttribute('style')`
  • Loading branch information
eoghanmurray committed Apr 12, 2023
1 parent d7beb11 commit d4f29f9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export default class MutationBuffer {
if (isIgnored(m.target, this.mirror)) {
return;
}
const unattachedDoc = new Document(); // avoid upsetting original document from a Content Security point of view
switch (m.type) {
case 'characterData': {
const value = m.target.textContent;
Expand Down Expand Up @@ -543,7 +544,7 @@ export default class MutationBuffer {
}

if (attributeName === 'style') {
const old = this.doc.createElement('span');
const old = unattachedDoc.createElement('span');
if (m.oldValue) {
old.setAttribute('style', m.oldValue);
}
Expand Down

0 comments on commit d4f29f9

Please sign in to comment.