-
-
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.
Browse files
Browse the repository at this point in the history
fix dynamic component bindings (#1489)
- Loading branch information
Showing
5 changed files
with
88 additions
and
6 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
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/dynamic-component-bindings-recreated-b/Green.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,11 @@ | ||
<p>green {foo}</p> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
foo: 'green' | ||
}; | ||
} | ||
}; | ||
</script> |
11 changes: 11 additions & 0 deletions
11
test/runtime/samples/dynamic-component-bindings-recreated-b/Red.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,11 @@ | ||
<p>red {foo}</p> | ||
|
||
<script> | ||
export default { | ||
data() { | ||
return { | ||
foo: 'red' | ||
}; | ||
} | ||
}; | ||
</script> |
36 changes: 36 additions & 0 deletions
36
test/runtime/samples/dynamic-component-bindings-recreated-b/_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,36 @@ | ||
export default { | ||
data: { | ||
x: true | ||
}, | ||
|
||
html: ` | ||
<p>parent green</p> | ||
<p>green green</p> | ||
`, | ||
|
||
test(assert, component, target) { | ||
// TODO replace this with component.set({ foo: undefined }) post-#1488 | ||
// component.set({ foo: undefined }); | ||
// delete component._state.foo; | ||
|
||
component.set({ | ||
x: false, | ||
foo: undefined | ||
}); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<p>parent red</p> | ||
<p>red red</p> | ||
`); | ||
|
||
component.set({ | ||
x: true, | ||
foo: undefined | ||
}); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
<p>parent green</p> | ||
<p>green green</p> | ||
`); | ||
} | ||
}; |
16 changes: 16 additions & 0 deletions
16
test/runtime/samples/dynamic-component-bindings-recreated-b/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,16 @@ | ||
<p>parent {foo}</p> | ||
<svelte:component this="{x ? Green : Red}" bind:foo /> | ||
|
||
<script> | ||
import Green from './Green.html'; | ||
import Red from './Red.html'; | ||
|
||
export default { | ||
data() { | ||
return { | ||
Green, | ||
Red | ||
}; | ||
} | ||
}; | ||
</script> |