observablehq / htl

A tagged template literal that allows safe interpolation of values into HTML, following the HTML5 spec
https://observablehq.com/@observablehq/htl
ISC License
305 stars 24 forks source link

Can’t set value of textarea by (only) interpolation #18

Closed tophtucker closed 3 years ago

tophtucker commented 4 years ago

Attempting to interpolate anything into a textarea:

html`<textarea>${"hello"}</textarea>`

Produces a textarea with the value "<!--::1-->"

image

(Which I guess is not terribly surprising since the "child is the value" behavior of textareas seems pretty nonstandard!)

tophtucker commented 4 years ago

Ah I guess it only breaks if the interpolated thing is the only child content. Adding some text fixes it image