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