Skip to content

Commit

Permalink
Merge pull request #11330 from emberjs/each-inverse-to-template
Browse files Browse the repository at this point in the history
Fix {{each}} inverse transitioning to template bug.
  • Loading branch information
rwjblue committed Jun 11, 2015
2 parents 7305122 + dafa0ad commit c81616c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"express": "^4.5.0",
"github": "^0.2.3",
"glob": "~4.3.2",
"htmlbars": "0.13.28",
"htmlbars": "0.13.30",
"qunit-extras": "^1.3.0",
"qunitjs": "^1.16.0",
"route-recognizer": "0.1.5",
Expand Down
34 changes: 34 additions & 0 deletions packages/ember-htmlbars/tests/helpers/each_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,40 @@ QUnit.test("it uses {{else}} when removing all items in an array", function() {
assertHTML(view, "Nothing");
});

QUnit.test("it can move to and from {{else}} properly when the backing array gains and looses items (#11140)", function() {
var items = A(['one', 'two']);
runDestroy(view);
view = EmberView.create({
template: compile("{{#each view.items}}{{this}}{{else}}Nothing{{/each}}"),
items
});

runAppend(view);

assertHTML(view, "onetwo");

run(function() {
items.shiftObject();
items.shiftObject();
});

assertHTML(view, "Nothing");

run(function() {
items.pushObject('three');
items.pushObject('four');
});

assertHTML(view, "threefour");

run(function() {
items.shiftObject();
items.shiftObject();
});

assertHTML(view, "Nothing");
});

QUnit.test("it works with the controller keyword", function() {
runDestroy(view);

Expand Down

0 comments on commit c81616c

Please sign in to comment.