Skip to content

Commit

Permalink
fix: attributeName readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
wfk007 committed Mar 14, 2023
1 parent f07f830 commit b0d5b8c
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ export default class MutationBuffer {
}
case 'attributes': {
const target = m.target as HTMLElement;
let value = (m.target as HTMLElement).getAttribute(m.attributeName!);
if (m.attributeName === 'value') {
let attributeName = m.attributeName as string;
let value = (m.target as HTMLElement).getAttribute(attributeName);
if (attributeName === 'value') {
value = maskInputValue({
maskInputOptions: this.maskInputOptions,
tagName: (m.target as HTMLElement).tagName,
Expand All @@ -508,10 +509,16 @@ export default class MutationBuffer {
);
if (
target.tagName === 'IFRAME' &&
m.attributeName === 'src' &&
(target as HTMLIFrameElement).contentDocument
attributeName === 'src' &&
!this.keepIframeSrcFn(value as string)
) {
return;
if (!(target as HTMLIFrameElement).contentDocument) {
// we can't record it directly as we can't see into it
// preserve the src attribute so a decision can be taken at replay time
attributeName = 'rr_src';
} else {
return;
}
}
if (!item) {
item = {
Expand All @@ -520,7 +527,7 @@ export default class MutationBuffer {
};
this.attributes.push(item);
}
if (m.attributeName === 'style') {
if (attributeName === 'style') {
const old = this.doc.createElement('span');
if (m.oldValue) {
old.setAttribute('style', m.oldValue);
Expand Down Expand Up @@ -552,12 +559,12 @@ export default class MutationBuffer {
styleObj[pname] = false; // delete
}
}
} else if (!ignoreAttribute(target.tagName, m.attributeName!, value)) {
} else if (!ignoreAttribute(target.tagName, attributeName, value)) {
// overwrite attribute if the mutations was triggered in same time
item.attributes[m.attributeName!] = transformAttribute(
item.attributes[attributeName] = transformAttribute(
this.doc,
target.tagName,
m.attributeName!,
attributeName,
value,
);
}
Expand Down

0 comments on commit b0d5b8c

Please sign in to comment.