jindw / xmldom

A PURE JS W3C Standard based(XML DOM Level2 CORE) DOMParser and XMLSerializer.
Other
819 stars 265 forks source link

parseFromString() ignore all the content before first <br/> #261

Open shiqing881215 opened 4 years ago

shiqing881215 commented 4 years ago

I'm using the following line const doc = new DOMParser().parseFromString(html, 'text/html'); and realize if html = '1<br/>2', the result doc only contains '<br/>2'. if html = '1<br/>2<br/>3', the result doc only contains '<br/>2<br/>3'.

Seems like if <br/> is the first tag, then any text content before the first <br/> is ignored.

Notice if you have some tag wrap that text content it can maintain (In other words, <br/> is not the first tag any more) if html = '<b>1</b><br/>2', the result doc is '<b>1</b><br/>2'.