-
-
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.
read values from range/number inputs as numbers - fixes #436
- Loading branch information
1 parent
a3ecb67
commit 605040d
Showing
5 changed files
with
75 additions
and
0 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,33 @@ | ||
export default { | ||
data: { | ||
count: 42 | ||
}, | ||
|
||
html: ` | ||
<input type='number'> | ||
<p>number 42</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, '42' ); | ||
|
||
const event = new window.Event( 'input' ); | ||
|
||
input.value = '43'; | ||
input.dispatchEvent( event ); | ||
|
||
assert.equal( component.get( 'count' ), 43 ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<input type='number'> | ||
<p>number 43</p> | ||
` ); | ||
|
||
component.set({ count: 44 }); | ||
assert.equal( input.value, '44' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<input type='number'> | ||
<p>number 44</p> | ||
` ); | ||
} | ||
}; |
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,2 @@ | ||
<input type='number' bind:value='count'> | ||
<p>{{typeof count}} {{count}}</p> |
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,33 @@ | ||
export default { | ||
data: { | ||
count: 42 | ||
}, | ||
|
||
html: ` | ||
<input type='range'> | ||
<p>number 42</p> | ||
`, | ||
|
||
test ( assert, component, target, window ) { | ||
const input = target.querySelector( 'input' ); | ||
assert.equal( input.value, '42' ); | ||
|
||
const event = new window.Event( 'input' ); | ||
|
||
input.value = '43'; | ||
input.dispatchEvent( event ); | ||
|
||
assert.equal( component.get( 'count' ), 43 ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 43</p> | ||
` ); | ||
|
||
component.set({ count: 44 }); | ||
assert.equal( input.value, '44' ); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<input type='range'> | ||
<p>number 44</p> | ||
` ); | ||
} | ||
}; |
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,2 @@ | ||
<input type='range' bind:value='count'> | ||
<p>{{typeof count}} {{count}}</p> |