-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11234 from rwjblue/fix-legacy-each-itemView-with-…
…non-context-shifting [BUGFIX beta] Fix {{each item in model itemViewClass="..."}}.
- Loading branch information
Showing
5 changed files
with
72 additions
and
14 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/ember-htmlbars/lib/helpers/-legacy-each-with-keyword.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,32 @@ | ||
import { get } from "ember-metal/property_get"; | ||
import { forEach } from "ember-metal/enumerable_utils"; | ||
import shouldDisplay from "ember-views/streams/should_display"; | ||
|
||
export default function legacyEachWithKeywordHelper(params, hash, blocks) { | ||
var list = params[0]; | ||
var keyPath = hash.key; | ||
var legacyKeyword = hash['-legacy-keyword']; | ||
|
||
if (shouldDisplay(list)) { | ||
forEach(list, function(item, i) { | ||
var self; | ||
if (legacyKeyword) { | ||
self = bindKeyword(self, legacyKeyword, item); | ||
} | ||
|
||
var key = keyPath ? get(item, keyPath) : String(i); | ||
blocks.template.yieldItem(key, [item, i], self); | ||
}); | ||
} else if (blocks.inverse.yield) { | ||
blocks.inverse.yield(); | ||
} | ||
} | ||
|
||
function bindKeyword(self, keyword, item) { | ||
return { | ||
self, | ||
[keyword]: item | ||
}; | ||
} | ||
|
||
export var deprecation = "Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead."; |
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
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
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 |
---|---|---|
@@ -1 +1,21 @@ | ||
{{~#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 view._emptyView}}{{view view._emptyView _defaultTagName=view._itemTagName}}{{/each~}} | ||
{{~#each view._arrangedContent -legacy-keyword=keyword as |item|~}} | ||
{{~#if keyword}} | ||
{{~#if attrs.itemViewClass~}} | ||
{{~#view attrs.itemViewClass _defaultTagName=view._itemTagName~}} | ||
{{~legacy-yield item~}} | ||
{{~/view~}} | ||
{{~else~}} | ||
{{~legacy-yield item~}} | ||
{{~/if~}} | ||
{{~else~}} | ||
{{~#if attrs.itemViewClass~}} | ||
{{~#view attrs.itemViewClass controller=item _defaultTagName=view._itemTagName~}} | ||
{{~legacy-yield item~}} | ||
{{~/view~}} | ||
{{~else~}} | ||
{{~legacy-yield item controller=item~}} | ||
{{~/if~}} | ||
{{~/if~}} | ||
{{~else if view._emptyView~}} | ||
{{~view view._emptyView _defaultTagName=view._itemTagName~}} | ||
{{~/each~}} |
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