Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix for #816 - avoid triggering a CSP (content security policy) error…
… with `.setAttribute('style')`
  • Loading branch information
eoghanmurray committed Apr 13, 2023
commit 386a318afc2308da370ebbe96266e5f496cf93fb
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