Netflix / x-element

A dead simple starting point for custom elements.
Apache License 2.0
29 stars 12 forks source link

Remove nullish coalescing for `textContent`. #205

Closed theengineear closed 3 days ago

theengineear commented 4 days ago

The default browser behavior when setting .textContent to null or undefined is to ultimately set the content to ''†. This is quite different from the behavior of createTextNode though… by splitting the text node creation into multiple steps we can consistently leverage .textContent and remove the need to ?? ''.

† Note that the WHATWG spec only defines that behavior for null, but in practice all modern browsers seem to treat undefined similarly.

Here’s the spec for reference. This is related to #204.

theengineear commented 4 days ago

FYI @klebba — Hopefully this one is pretty easy to review. Shouldn’t be too controversial.

theengineear commented 3 days ago

@klebba — Gonna get this in to unblock myself on some other work.