-
-
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
allow dynamic each-block to have static else-block
- Loading branch information
Showing
3 changed files
with
54 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
27 changes: 27 additions & 0 deletions
27
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,27 @@ | ||
export default { | ||
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}} |