Skip to content

Commit 6074178

Browse files
authoredApr 2, 2017
Merge pull request #427 from sveltejs/gh-423
Make <select> elements use .value prop to update value
2 parents 0d5d7ff + 96fa0a3 commit 6074178

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed
 

‎src/generators/dom/visitors/attributes/lookup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const lookup = {
109109
title: {},
110110
type: { appliesTo: [ 'button', 'input', 'command', 'embed', 'object', 'script', 'source', 'style', 'menu' ] },
111111
usemap: { propertyName: 'useMap', appliesTo: [ 'img', 'input', 'object' ] },
112-
value: { appliesTo: [ 'button', 'option', 'input', 'li', 'meter', 'progress', 'param' ] },
112+
value: { appliesTo: [ 'button', 'option', 'input', 'li', 'meter', 'progress', 'param', 'select' ] },
113113
width: { appliesTo: [ 'canvas', 'embed', 'iframe', 'img', 'input', 'object', 'video' ] },
114114
wrap: { appliesTo: [ 'textarea' ] }
115115
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export default {
2+
'skip-ssr': true,
3+
4+
data: {
5+
foo: 'a'
6+
},
7+
8+
test ( assert, component, target ) {
9+
const options = target.querySelectorAll( 'option' );
10+
11+
assert.equal( options[0].selected, true );
12+
assert.equal( options[1].selected, false );
13+
14+
component.set( { foo: 'b' } );
15+
16+
assert.equal( options[0].selected, false );
17+
assert.equal( options[1].selected, true );
18+
}
19+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<select value="{{foo}}">
2+
<option>a</option>
3+
<option>b</option>
4+
</select>

0 commit comments

Comments
 (0)