-
-
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.
allow dynamic each-block to have static else-block
- Loading branch information
1 parent
629584d
commit fce3f34
Showing
3 changed files
with
56 additions
and
10 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
29 changes: 29 additions & 0 deletions
29
test/runtime/samples/each-block-dynamic-else-static/_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,29 @@ | ||
export default { | ||
solo: true, | ||
|
||
data: { | ||
animals: [ 'alpaca', 'baboon', 'capybara' ] | ||
}, | ||
|
||
html: ` | ||
<p>alpaca</p> | ||
<p>baboon</p> | ||
<p>capybara</p> | ||
`, | ||
|
||
test ( assert, component, target ) { | ||
component.set({ animals: [] }); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<p>no animals</p> | ||
` ); | ||
|
||
// trigger an 'update' of the else block, to ensure that | ||
// non-existent update method is not called | ||
component.set({ animals: [] }); | ||
|
||
component.set({ animals: ['wombat'] }); | ||
assert.htmlEqual( target.innerHTML, ` | ||
<p>wombat</p> | ||
` ); | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/runtime/samples/each-block-dynamic-else-static/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,5 @@ | ||
{{#each animals as animal}} | ||
<p>{{animal}}</p> | ||
{{else}} | ||
<p>no animals</p> | ||
{{/each}} |