-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prevent mutation bug from incorrectly calling observer (fixes #804)
- Loading branch information
1 parent
e30ff54
commit fb97256
Showing
4 changed files
with
51 additions
and
1 deletion.
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
1 change: 1 addition & 0 deletions
1
test/runtime/samples/observe-binding-ignores-unchanged/Nested.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 type="number" bind:value="field1"> |
28 changes: 28 additions & 0 deletions
28
test/runtime/samples/observe-binding-ignores-unchanged/_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,28 @@ | ||
export default { | ||
html: ` | ||
<input type='number'> | ||
<p>field1: 1</p> | ||
<p>field2: 2</p> | ||
`, | ||
|
||
test(assert, component, target, window) { | ||
let triggered = false; | ||
component.refs.nested.observe('field2', () => { | ||
triggered = true; | ||
}, { init: false }); | ||
|
||
const input = target.querySelector('input'); | ||
const event = new window.Event('input'); | ||
|
||
input.value = 3; | ||
input.dispatchEvent(event); // will throw error if observer fires incorrectly | ||
|
||
assert.ok(!triggered); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<input type='number'> | ||
<p>field1: 3</p> | ||
<p>field2: 2</p> | ||
`); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
test/runtime/samples/observe-binding-ignores-unchanged/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,21 @@ | ||
<Nested ref:nested bind:field1="myObject.field1" bind:field2="myObject.field2" /> | ||
<p>field1: {{myObject.field1}}</p> | ||
<p>field2: {{myObject.field2}}</p> | ||
|
||
<script> | ||
import Nested from './Nested.html'; | ||
|
||
export default { | ||
components: { | ||
Nested | ||
}, | ||
data() { | ||
return { | ||
myObject: { | ||
field1: 1, | ||
field2: 2 | ||
} | ||
}; | ||
} | ||
}; | ||
</script> |