You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently using Unsafe.data to bring known-good HTML fragments (produced by a reasonable markdown->HTML generator) into the tyxml world. AIUI, that should be okay, but perhaps the current issue demonstrates that it is not.
When Unsafe.data-produced content that contains a self-closed tag (e.g. <div/>) is interpolated into a JSX template, the structure surrounding that interpolation is changed. For example, interpolating the poison element as shown here yields an HTML document where the div containing "2" is pulled into its predecessor, so that both "1" and "2" are surrounded by a red border:
In general, it's better to debug these kind of things by looking at the emitted HTML before the browser result.
In this case, the emited HTML is:
<html><head><title>Home</title></head><body><divstyle="border:solid red 1px">
1
<div/>
</div><div>2</div></body></html>
Which is what you wanted ... but also completely invalid HTML, and triggers the error recovery mode in the browser's HTML parsing, resulting in the wrong result you see. <div/> is not a thing in valid HTML. If you replace by <div></div>, you get what you want.
I'm currently using
Unsafe.data
to bring known-good HTML fragments (produced by a reasonable markdown->HTML generator) into the tyxml world. AIUI, that should be okay, but perhaps the current issue demonstrates that it is not.When
Unsafe.data
-produced content that contains a self-closed tag (e.g.<div/>
) is interpolated into a JSX template, the structure surrounding that interpolation is changed. For example, interpolating thepoison
element as shown here yields an HTML document where the div containing "2" is pulled into its predecessor, so that both "1" and "2" are surrounded by a red border:A Dream playground example is available with this code already populated, demonstrating the problem: http://dream.as/XYZ68EQPDKVt
A quick side test of this using only tyxml (i.e. no jsx) yields the expected behaviour, so it seems the interpolation into jsx is the culprit somehow.
The text was updated successfully, but these errors were encountered: