From 49c88b16f22e3e227054b328453040f1ba350f56 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 19 May 2015 21:30:04 -0400 Subject: [PATCH] [BUGFIX beta] Fix {{each}} with `itemViewClass` specified `tagName`. --- .../lib/templates/legacy-each.hbs | 2 +- .../ember-htmlbars/tests/helpers/each_test.js | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/ember-htmlbars/lib/templates/legacy-each.hbs b/packages/ember-htmlbars/lib/templates/legacy-each.hbs index c109ab3d491..c6b7983fe04 100644 --- a/packages/ember-htmlbars/lib/templates/legacy-each.hbs +++ b/packages/ember-htmlbars/lib/templates/legacy-each.hbs @@ -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~}} diff --git a/packages/ember-htmlbars/tests/helpers/each_test.js b/packages/ember-htmlbars/tests/helpers/each_test.js index eebf4840529..d64c36c0730 100644 --- a/packages/ember-htmlbars/tests/helpers/each_test.js +++ b/packages/ember-htmlbars/tests/helpers/each_test.js @@ -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"}}'), @@ -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(''), + 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}}")