diff --git a/src/Editing.ts b/src/Editing.ts index 88611e5550..fa25f8be5e 100644 --- a/src/Editing.ts +++ b/src/Editing.ts @@ -382,7 +382,8 @@ export function Editing(Base: TBase) { ); Object.entries(action.newAttributes).forEach(([key, value]) => { - if (value) action.element.setAttribute(key, value); + if (value !== null && value !== undefined) + action.element.setAttribute(key, value); }); return true; diff --git a/test/unit/Editing.test.ts b/test/unit/Editing.test.ts index 04413af5a8..ca49ffcc77 100644 --- a/test/unit/Editing.test.ts +++ b/test/unit/Editing.test.ts @@ -341,6 +341,19 @@ describe('EditingElement', () => { expect(element).to.not.have.attribute('desc'); }); + it('allows empty string as attribute value', () => { + const newAttributes: Record = {}; + newAttributes['name'] = ''; + + elm.dispatchEvent( + newActionEvent(createUpdateAction(element, newAttributes)) + ); + + expect(element.parentElement).to.equal(parent); + expect(element).to.have.attribute('name', ''); + expect(element).to.not.have.attribute('desc'); + }); + it('does not update an element in case of name conflict', () => { const newAttributes: Record = {}; newAttributes['name'] = 'Q02';