-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update select value bindings at the end of the cycle (fixes #476)
- Loading branch information
1 parent
ef630b1
commit 02e55e8
Showing
3 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
export default { | ||
data: { | ||
items: [], | ||
selected: null | ||
}, | ||
|
||
html: ` | ||
<select></select> | ||
<p>selected: nothing</p> | ||
`, | ||
|
||
test ( assert, component, target ) { | ||
component.set({ | ||
items: [ 'one', 'two', 'three' ], | ||
selected: 'two' | ||
}); | ||
|
||
const options = target.querySelectorAll( 'option' ); | ||
assert.ok( !options[0].selected ); | ||
assert.ok( options[1].selected ); | ||
assert.ok( !options[2].selected ); | ||
|
||
assert.htmlEqual( target.innerHTML, ` | ||
<select> | ||
<option>one</option> | ||
<option>two</option> | ||
<option>three</option> | ||
</select> | ||
<p>selected: two</p> | ||
` ); | ||
|
||
component.destroy(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<select bind:value='selected'> | ||
{{#each items as item}} | ||
<option>{{item}}</option> | ||
{{/each}} | ||
</select> | ||
|
||
<p>selected: {{selected || 'nothing'}}</p> |