From fd76a7bcd8d9650f317e859f84b014ff6e4f6a5c Mon Sep 17 00:00:00 2001 From: Justin Halsall Date: Wed, 1 Apr 2026 12:00:00 +0800 Subject: [PATCH] Fixes to #628 to help it pass typescript's type checking (#634) * My best interpretation of what the typings should look like after merge of #464 * Apply variable name changes as per Juice10 review Co-authored-by: Justin Halsall * fix types Co-authored-by: Eoghan Murray --- src/record/mutation.ts | 36 +++++++++++++++++++++++------------- src/replay/index.ts | 18 ++++++++++++------ src/types.ts | 4 +++- typings/types.d.ts | 8 ++++++-- 4 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/record/mutation.ts b/src/record/mutation.ts index 2344265c..216c76a3 100644 --- a/src/record/mutation.ts +++ b/src/record/mutation.ts @@ -21,6 +21,7 @@ import { removedNodeMutation, addedNodeMutation, Mirror, + styleAttributeValue, } from '../types'; import { isBlocked, @@ -449,7 +450,7 @@ export default class MutationBuffer { break; } case 'attributes': { - const target = (m.target as HTMLElement); + const target = m.target as HTMLElement; let value = (m.target as HTMLElement).getAttribute(m.attributeName!); if (m.attributeName === 'value') { value = maskInputValue({ @@ -475,29 +476,38 @@ export default class MutationBuffer { } if (m.attributeName === 'style') { const old = this.doc.createElement('span'); - old.setAttribute('style', m.oldValue); - if (item.attributes['style'] === undefined) { + if (m.oldValue) { + old.setAttribute('style', m.oldValue); + } + if ( + item.attributes['style'] === undefined || + item.attributes['style'] === null + ) { item.attributes['style'] = {}; } - for (let i=0; i