plate icon indicating copy to clipboard operation
plate copied to clipboard

<a> is removed on normalize if only child is <img> and it has siblings

Open whytspace opened this issue 4 years ago • 0 comments

Description

I tried to parse the following html string

<!-- this does not work -->
<p><a href="#1"><img src="https://source.unsplash.com/kFrdX5IeQzI" /></a>Foo</p>
<!-- this works -->
<p><a href="#1"><img src="https://source.unsplash.com/kFrdX5IeQzI" /></a></p>

Parsing worked fine but during normalization the link is removed. The problem seems to be coming from the withRemoveEmptyNodes function

Sandbox

https://codesandbox.io/s/deserialize-link-image-ijgzq?file=/index.tsx

Expectation

The link should not be removed, since it is clearly not empty! It contains an image.

Environment

  • slate: 0.60.11
  • slate-react: 0.60.11
  • browser: chrome

whytspace avatar Aug 17 '21 11:08 whytspace