-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
Both fluent-dom
and fluent-react
currently use the <template>
element to safely parse markup in translations. The <template>
element internally uses the HTML parser. This is similar in effect to using DOMParser.parseFromString
with text/html
as supported type.
The HTML parser has rather strict rules on parsing void elements, unlike the XML parser. It only allows the elements known to be void (e.g. input
) to be self-closing (<element/>
). Non-void elements are parsed as if they weren't properly closed.
This means that the following markup:
A <span/> B
…is parsed as:
A <span> B</span>
The consequence for overlays is that localizers can't use the self-closing form with non-void elements. Admittedly, they're not valid HTML markup, but the difference is rather subtle:
# This inserts "!" into the span.
hello = Hello, <span data-l10n-name="user" />!
# This works as expected.
hello = Hello, <span data-l10n-name="user"></span>!