Skip to content

Commit

Permalink
Merge pull request #11228 from rwjblue/fix-legacy-each-itemViewClass-…
Browse files Browse the repository at this point in the history
…tagName

[BUGFIX beta] Fix {{each}} with `itemViewClass` specified `tagName`.
  • Loading branch information
rwjblue committed May 20, 2015
2 parents 79e764e + 49c88b1 commit d5a4719
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ember-htmlbars/lib/templates/legacy-each.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{~#each view._arrangedContent as |item|}}{{#if attrs.itemViewClass}}{{#view attrs.itemViewClass controller=item tagName=view._itemTagName}}{{legacy-yield item}}{{/view}}{{else}}{{legacy-yield item controller=item}}{{/if}}{{else if attrs.emptyViewClass}}{{view attrs.emptyViewClass tagName=view._itemTagName}}{{/each~}}
{{~#each view._arrangedContent as |item|}}{{#if attrs.itemViewClass}}{{#view attrs.itemViewClass controller=item _defaultTagName=view._itemTagName}}{{legacy-yield item}}{{/view}}{{else}}{{legacy-yield item controller=item}}{{/if}}{{else if attrs.emptyViewClass}}{{view attrs.emptyViewClass _defaultTagName=view._itemTagName}}{{/each~}}
21 changes: 20 additions & 1 deletion packages/ember-htmlbars/tests/helpers/each_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ QUnit.test("it supports {{itemViewClass=}} via container", function() {
assertText(view, "Steve HoltAnnabelle");
});

QUnit.test("it supports {{itemViewClass=}} with tagName (DEPRECATED)", function() {
QUnit.test("it supports {{itemViewClass=}} with each view tagName (DEPRECATED)", function() {
runDestroy(view);
view = EmberView.create({
template: templateFor('{{each view.people itemViewClass=MyView tagName="ul"}}'),
Expand All @@ -603,6 +603,25 @@ QUnit.test("it supports {{itemViewClass=}} with tagName (DEPRECATED)", function(
equal(view.$('ul li').text(), 'Steve HoltAnnabelle');
});

QUnit.test("it supports {{itemViewClass=}} with tagName in itemViewClass (DEPRECATED)", function() {
runDestroy(view);
registry.register('view:li-view', EmberView.extend({
tagName: 'li'
}));

view = EmberView.create({
template: templateFor('<ul>{{#each view.people itemViewClass="li-view" as |item|}}{{item.name}}{{/each}}</ul>'),
people: people,
container: container
});

runAppend(view);

equal(view.$('ul').length, 1, 'rendered ul tag');
equal(view.$('ul li').length, 2, 'rendered 2 li tags');
equal(view.$('ul li').text(), 'Steve HoltAnnabelle');
});

QUnit.test("it supports {{itemViewClass=}} with in format", function() {
MyView = EmberView.extend({
template: templateFor("{{person.name}}")
Expand Down

0 comments on commit d5a4719

Please sign in to comment.