- changed status to open
isHTML fails to parse HTML
isHTML
parses as XML rather than HTML.
This makes the parses too strict, preventing the rendering of some markup, that is otherwise considered valid HTML when using text/html
.
This makes the GFI wrongly output markup as text, rather than rendering it as html. (see link below)
Examples of valid HTML, that fails by parsing as XML:
<div>Foobar</div><p>Große Str. 123, 12345 Stadt<br /><a href="https://example.org" class="link">Zum Standort</a></p>
<span>Foo</span><span>Bar</span>
<p>Foo</p><hr><p>Bar</p>
To test results:
htmlString = `<p>Foo</p>
<p>Bar</p>`;
errorNode = new DOMParser().parseFromString(htmlString, "text/xml").querySelector("parsererror");
console.log('RESULT:', errorNode ? 'INVALID' : 'VALID');
Note:
text/xml
expects a single root node and does fail when parsing multiple nodes like in the examples above.
Using text/html
shows that multiple nodes are valid HTML.
Also if rendering a single root is a concern for some reason, should not be a problem given that the parsed string is being rendered inside a <div> that acts itself as root node.
Comments (5)
-
-
reporter Hello, is there any feedback about the behavior?
Is it planned for a fix? -
-
assigned issue to
-
assigned issue to
-
@ Igor we are going to check it
-
- changed status to resolved
isHTML
will now recognize the given examples of html als valid. These changes will be included in the next release. - Log in to comment