html-to-react
html-to-react copied to clipboard
Strip out white space text nodes
Fixes #30 ("Should not insert spans into tables even if there is white space") by stripping out all white-space text nodes.
This changes non-table nodes too, e.g.:
<div> </div>
into <div></div>
<div> <span>hi</span>bye</div>
into <div><span>hi</span>bye</div>
.
I'm not sure if that is desirable. If it's not, is there a better solution?
Coverage decreased (-1.1%) to 98.876% when pulling a44d4efded8163fabaf9d92600a7395c2b2bd84c on TerriaJS:tablespan into 3bf4bd4b4d45a46e8ce7fcd6af538a3c80eaa7ea on mikenikles:master.
Might this PR be unnecessary as #30 is already closed?
Could it be better to leave to some HTML tidying library to handle concerns such as unnecessary whitespace, which this PR addresses?
Thanks @aknuds1 - I agree, this feels like too heavy a solution to the problem. I like your idea of leaving it to another library to deal with this.
Is it a worry that the test in #30 passes but still produces a warning that a span
has been introduced? This may be a spurious comparison, but eg.
<div dangerouslySetInnerHTML={{__html: '<table><tbody> <tr><td>x</td><td>3</td></tr></tbody></table>'}} />
doesn't produce a warning.