Since we attempt to fold expressions embedded in data directly into markup, this is considered equivalent to empty markup,
html``
which evaluates to null. But if the intent of HTL is that embedded expressions don’t change the structure of the resulting HTML, then we must ensure that we only fold data expressions into markup if there is a preceding or following text node.
For example, here’s another case where we want to generate a text node:
html`${""}<span>hello`
Alternatively, we could have empty markup return an empty text node, and then this would return an empty text node, too:
html`${""}`
That kind of makes sense, but it would mean that any embedded expression that evaluates to null would now insert an empty text node rather than inserting nothing, which feels wrong, too.
Since we attempt to fold expressions embedded in data directly into markup, this is considered equivalent to empty markup,
which evaluates to null. But if the intent of HTL is that embedded expressions don’t change the structure of the resulting HTML, then we must ensure that we only fold data expressions into markup if there is a preceding or following text node.
For example, here’s another case where we want to generate a text node:
Alternatively, we could have empty markup return an empty text node, and then this would return an empty text node, too:
That kind of makes sense, but it would mean that any embedded expression that evaluates to null would now insert an empty text node rather than inserting nothing, which feels wrong, too.