HubSpot / draft-convert

Extensibly serialize & deserialize Draft.js ContentState with HTML.
Apache License 2.0
484 stars 94 forks source link

Stop replacing empty string returns from entityToHTML with originalText #171

Closed maxwellskala closed 4 years ago

maxwellskala commented 4 years ago

getElementHTML can return both undefined and null, in which case blockEntities should replace that "html" with originalText. However, the existing check for this case was also replacing '', since it is falsy, meaing '' || originalText resolved to originalText.

Before this change, it was impossible to fully strip entity text when converting to HTML without including dummy tags with dummy children (e.g. <span>{''}</span>).