treat <textarea> children the same as a value attribute

pull/599/head
Rich Harris 8 years ago
parent 8d2607c37d
commit b828fdf855

@ -107,6 +107,20 @@ export default function visitElement ( generator: DomGenerator, block: Block, st
}
if ( node.name !== 'select' ) {
if ( node.name === 'textarea' ) {
// this is an egregious hack, but it's the easiest way to get <textarea>
// children treated the same way as a value attribute
if ( node.children.length > 0 ) {
node.attributes.push({
type: 'Attribute',
name: 'value',
value: node.children
});
node.children = [];
}
}
// <select> value attributes are an annoying special case — it must be handled
// *after* its children have been updated
visitAttributesAndAddProps();

@ -0,0 +1,17 @@
export default {
'skip-ssr': true, // SSR behaviour is awkwardly different
data: {
foo: 42
},
html: `<textarea></textarea>`,
test ( assert, component, target ) {
const textarea = target.querySelector( 'textarea' );
assert.strictEqual( textarea.value, `\n\t<p>not actually an element. 42</p>\n` );
component.set({ foo: 43 });
assert.strictEqual( textarea.value, `\n\t<p>not actually an element. 43</p>\n` );
}
};

@ -0,0 +1,3 @@
<textarea>
<p>not actually an element. {{foo}}</p>
</textarea>
Loading…
Cancel
Save