Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shiqing881215 opened this issue Apr 24, 2020 · 0 comments
Open

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

shiqing881215 opened this issue Apr 24, 2020 · 0 comments

Comments

@shiqing881215
Copy link

shiqing881215 commented Apr 24, 2020

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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant