Skip to content

Commit

Permalink
Fix for rrweb-io#816 - avoid triggering a CSP (content security polic…
Browse files Browse the repository at this point in the history
…y) error with `.setAttribute('style')`
  • Loading branch information
eoghanmurray committed Mar 3, 2022
1 parent bd144be commit 92febda
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 @@ -426,6 +426,7 @@ export default class MutationBuffer {
if (isIgnored(m.target)) {
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 @@ -472,7 +473,7 @@ export default class MutationBuffer {
this.attributes.push(item);
}
if (m.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 92febda

Please sign in to comment.