Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] Fix {{each}} with itemViewClass specified tagName. #11228

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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