-
-
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.
- Loading branch information
Showing
24 changed files
with
226 additions
and
62 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
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
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
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,8 @@ | ||
{ | ||
"message": "comment was left open, expected -->", | ||
"loc": { | ||
"line": 1, | ||
"column": 24 | ||
}, | ||
"pos": 24 | ||
} |
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 @@ | ||
<!-- an unclosed comment |
1 change: 1 addition & 0 deletions
1
test/runtime/samples/store-component-binding-deep/TextInput.html
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 @@ | ||
<input bind:value> |
42 changes: 42 additions & 0 deletions
42
test/runtime/samples/store-component-binding-deep/_config.js
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,42 @@ | ||
import { Store } from '../../../../store.js'; | ||
|
||
const store = new Store({ | ||
name: { | ||
value: 'world' | ||
} | ||
}); | ||
|
||
export default { | ||
store, | ||
|
||
html: ` | ||
<h1>Hello world!</h1> | ||
<input> | ||
`, | ||
|
||
test(assert, component, target, window) { | ||
const input = target.querySelector('input'); | ||
const event = new window.Event('input'); | ||
|
||
const changeRecord = []; | ||
store.onchange((state, changes) => { | ||
changeRecord.push({ state, changes }); | ||
}); | ||
|
||
input.value = 'everybody'; | ||
input.dispatchEvent(event); | ||
|
||
assert.equal(store.get('name').value, 'everybody'); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<h1>Hello everybody!</h1> | ||
<input> | ||
`); | ||
|
||
assert.deepEqual(changeRecord, [ | ||
{ | ||
state: { name: { value: 'everybody' } }, | ||
changes: { name: true } | ||
} | ||
]); | ||
} | ||
}; |
10 changes: 10 additions & 0 deletions
10
test/runtime/samples/store-component-binding-deep/main.html
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,10 @@ | ||
<h1>Hello {{$name.value}}!</h1> | ||
<TextInput bind:value=$name.value/> | ||
|
||
<script> | ||
import TextInput from './TextInput.html'; | ||
|
||
export default { | ||
components: { TextInput } | ||
}; | ||
</script> |
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 @@ | ||
<input bind:value> |
30 changes: 30 additions & 0 deletions
30
test/runtime/samples/store-component-binding-each/_config.js
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,30 @@ | ||
import { Store } from '../../../../store.js'; | ||
|
||
const store = new Store({ | ||
a: ['foo', 'bar', 'baz'] | ||
}); | ||
|
||
export default { | ||
store, | ||
|
||
html: ` | ||
<input><input><input> | ||
<p>foo, bar, baz</p> | ||
`, | ||
|
||
test(assert, component, target, window) { | ||
const event = new window.MouseEvent('input'); | ||
const inputs = target.querySelectorAll('input'); | ||
|
||
inputs[0].value = 'blah'; | ||
inputs[0].dispatchEvent(event); | ||
|
||
assert.deepEqual(store.get('a'), ['blah', 'bar', 'baz']); | ||
assert.htmlEqual(target.innerHTML, ` | ||
<input><input><input> | ||
<p>blah, bar, baz</p> | ||
`); | ||
|
||
component.destroy(); | ||
}, | ||
}; |
15 changes: 15 additions & 0 deletions
15
test/runtime/samples/store-component-binding-each/main.html
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,15 @@ | ||
{{#each $a as x}} | ||
<Widget bind:value='x'/> | ||
{{/each}} | ||
|
||
<p>{{$a.join(', ')}}</p> | ||
|
||
<script> | ||
import Widget from './Widget.html'; | ||
|
||
export default { | ||
components: { | ||
Widget | ||
} | ||
}; | ||
</script> |
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
Oops, something went wrong.