Skip to content

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

Open
@shiqing881215

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions