dont create whitespace nodes inside elements like <select> (#189)

pull/459/head
Rich Harris 8 years ago
parent 2e946e0e93
commit 182a04e8fc

@ -1,6 +1,21 @@
// Whitespace inside one of these elements will not result in
// a whitespace node being created in any circumstances. (This
// list is almost certainly very incomplete)
const elementsWithoutText = new Set([
'audio',
'datalist',
'dl',
'ol',
'optgroup',
'select',
'ul',
'video'
]);
export default function visitText ( generator, block, state, node ) {
if ( state.namespace && !/\S/.test( node.data ) ) {
return;
if ( !/\S/.test( node.data ) ) {
if ( state.namespace ) return;
if ( elementsWithoutText.has( state.parentNodeName) ) return;
}
const name = block.getUniqueName( `text` );

@ -0,0 +1,6 @@
export default {
test ( assert, component, target ) {
const select = target.querySelector( 'select' );
assert.equal( select.childNodes.length, 3 );
}
};

@ -0,0 +1,5 @@
<select>
<option>a</option>
<option>b</option>
<option>c</option>
</select>
Loading…
Cancel
Save