-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Description
While fixing #178 it occurred to me that there are some nodes, like <datalist>
, where it doesn't make sense to have text node children. The browser agrees:
document.body.innerHTML = `
<div>
<span>a</span>
<span>b</span>
</div>
`;
console.log( document.body.querySelector( 'div' ).childNodes );
// [ text, span, text, span, text ]
document.body.innerHTML = `
<datalist>
<option value='a'/>
<option value='b'/>
</datalist>
`;
console.log( document.body.querySelector( 'datalist' ).childNodes );
// [ text, option, option ]
Not sure what the first text node is doing there in the second case. Anyway, Svelte should be smart enough not to create text nodes inside elements where they're meaningless.
Additionally, we could collapse excess whitespace between nodes that aren't inside a <pre>
element, since these are equivalent:
<p>one</p> <p>two</p>
<p> one </p>
<p> two </p>
(That's not strictly true, since it's dependent on CSS, so there probably needs to be a preserveWhitespace: true
option if we did that.)
maxmilton, jarrodldavis, neuronetio, vladshcherbin, vtenfys and 25 moreelron