diff --git a/src/record/mutation.ts b/src/record/mutation.ts index 04f0065b80..2344265c27 100644 --- a/src/record/mutation.ts +++ b/src/record/mutation.ts @@ -449,6 +449,7 @@ export default class MutationBuffer { break; } case 'attributes': { + const target = (m.target as HTMLElement); let value = (m.target as HTMLElement).getAttribute(m.attributeName!); if (m.attributeName === 'value') { value = maskInputValue({ @@ -472,13 +473,42 @@ export default class MutationBuffer { }; this.attributes.push(item); } - // overwrite attribute if the mutations was triggered in same time - item.attributes[m.attributeName!] = transformAttribute( - this.doc, - (m.target as HTMLElement).tagName, - m.attributeName!, - value!, - ); + if (m.attributeName === 'style') { + const old = this.doc.createElement('span'); + old.setAttribute('style', m.oldValue); + if (item.attributes['style'] === undefined) { + item.attributes['style'] = {}; + } + for (let i=0; i { - if ( - 'style' in a.attributes && - coordinatesReg.test(a.attributes.style!) - ) { - a.attributes.style = a.attributes.style!.replace( - coordinatesReg, - '$1: Npx', - ); + if ('style' in a.attributes && a.attributes.style && typeof a.attributes.style === 'object') { + for (const [k, v] of Object.entries(a.attributes.style)) { + if (Array.isArray(v)) { + if (coordinatesReg.test(k + ': ' + v[0])) { + // TODO: could round the number here instead depending on what's coming out of various test envs + a.attributes.style[k] = ['Npx', v[1]]; + } + } else if (typeof v === 'string') { + if (coordinatesReg.test(k + ': ' + v)) { + a.attributes.style[k] = 'Npx'; + } + } + coordinatesReg.lastIndex = 0; // wow, a real wart in ECMAScript + } } }); s.data.adds.forEach((add) => { @@ -97,6 +103,7 @@ function stringifySnapshots(snapshots: eventWithTime[]): string { '$1: Npx', ); } + coordinatesReg.lastIndex = 0; // wow, a real wart in ECMAScript }); } delete s.timestamp;