diff --git a/packages/ember-htmlbars/lib/helpers/each.js b/packages/ember-htmlbars/lib/helpers/each.js
index 77e14fcdb68..8f64ab9ce47 100644
--- a/packages/ember-htmlbars/lib/helpers/each.js
+++ b/packages/ember-htmlbars/lib/helpers/each.js
@@ -1,6 +1,4 @@
-import Ember from 'ember-metal/core';
import Error from 'ember-metal/error';
-import normalizeSelf from 'ember-htmlbars/utils/normalize-self';
import shouldDisplay from 'ember-views/streams/should_display';
import decodeEachKey from 'ember-htmlbars/utils/decode-each-key';
@@ -75,25 +73,16 @@ export default function eachHelper(params, hash, blocks) {
var list = params[0];
var keyPath = hash.key;
- if (blocks.template.arity === 0) {
- Ember.deprecate(deprecation, false, { id: 'ember-htmlbars.each-helper-arity', until: '3.0.0' });
- }
-
if (shouldDisplay(list)) {
let seenKeys = {};
forEach(list, (item, i) => {
- var self;
- if (blocks.template.arity === 0) {
- self = normalizeSelf(item);
- }
-
var key = decodeEachKey(item, keyPath, i);
if (seenKeys[key] === true) {
throw new Error(`Duplicate key found ('${key}') for '{{each}}' helper, please use a unique key or switch to '{{#each model key="@index"}}{{/each}}'.`);
} else {
seenKeys[key] = true;
}
- blocks.template.yieldItem(key, [item, i], self);
+ blocks.template.yieldItem(key, [item, i]);
});
} else if (blocks.inverse.yield) {
blocks.inverse.yield();
@@ -103,5 +92,3 @@ export default function eachHelper(params, hash, blocks) {
function forEach(iterable, cb) {
return iterable.forEach ? iterable.forEach(cb) : Array.prototype.forEach.call(iterable, cb);
}
-
-export var deprecation = 'Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.';
diff --git a/packages/ember-htmlbars/tests/compat/make_bound_helper_test.js b/packages/ember-htmlbars/tests/compat/make_bound_helper_test.js
index 0aa9851d5b6..ca9e6ed69d5 100644
--- a/packages/ember-htmlbars/tests/compat/make_bound_helper_test.js
+++ b/packages/ember-htmlbars/tests/compat/make_bound_helper_test.js
@@ -13,7 +13,6 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import { dasherize } from 'ember-runtime/system/string';
import EmberHandlebars from 'ember-htmlbars/compat';
-import { deprecation as eachDeprecation } from 'ember-htmlbars/helpers/each';
var compile, helpers, helper;
compile = EmberHandlebars.compile;
@@ -52,12 +51,10 @@ QUnit.module('ember-htmlbars: compat - makeBoundHelper', {
});
QUnit.test('primitives should work correctly [DEPRECATED]', function() {
- expectDeprecation(eachDeprecation);
-
view = EmberView.create({
prims: Ember.A(['string', 12]),
- template: compile('{{#each view.prims}}{{#if this}}inside-if{{/if}}{{/each}}')
+ template: compile('{{#each view.prims as |prim|}}{{#if prim}}inside-if{{/if}}{{/each}}')
});
runAppend(view);
@@ -486,12 +483,10 @@ QUnit.test('bound helpers can handle nulls in array (with primitives) [DEPRECATE
controller: EmberObject.create({
things: A([null, 0, undefined, false, 'OMG'])
}),
- template: compile('{{#each things}}{{this}}|{{reverse this}} {{/each}}{{#each things as |thing|}}{{thing}}|{{reverse thing}} {{/each}}')
+ template: compile('{{#each things as |thing|}}{{thing}}|{{reverse thing}} {{/each}}{{#each things as |thing|}}{{thing}}|{{reverse thing}} {{/each}}')
});
- expectDeprecation(function() {
- runAppend(view);
- }, eachDeprecation);
+ runAppend(view);
equal(view.$().text(), '|NOPE 0|NOPE |NOPE false|NOPE OMG|GMO |NOPE 0|NOPE |NOPE false|NOPE OMG|GMO ', 'helper output is correct');
@@ -514,12 +509,10 @@ QUnit.test('bound helpers can handle nulls in array (with objects)', function()
controller: EmberObject.create({
things: A([null, { foo: 5 }])
}),
- template: compile('{{#each things}}{{foo}}|{{print-foo this}} {{/each}}{{#each things as |thing|}}{{thing.foo}}|{{print-foo thing}} {{/each}}')
+ template: compile('{{#each things as |thing|}}{{thing.foo}}|{{print-foo thing}} {{/each}}{{#each things as |thing|}}{{thing.foo}}|{{print-foo thing}} {{/each}}')
});
- expectDeprecation(function() {
- runAppend(view);
- }, eachDeprecation);
+ runAppend(view);
equal(view.$().text(), '|NOPE 5|5 |NOPE 5|5 ', 'helper output is correct');
diff --git a/packages/ember-htmlbars/tests/helpers/collection_test.js b/packages/ember-htmlbars/tests/helpers/collection_test.js
index 89b3161a2b9..72067ff8366 100644
--- a/packages/ember-htmlbars/tests/helpers/collection_test.js
+++ b/packages/ember-htmlbars/tests/helpers/collection_test.js
@@ -439,7 +439,7 @@ QUnit.test('should work inside a bound {{#if}}', function() {
QUnit.test('should pass content as context when using {{#each}} helper [DEPRECATED]', function() {
view = EmberView.create({
- template: compile('{{#each view.releases}}Mac OS X {{version}}: {{name}} {{/each}}'),
+ template: compile('{{#each view.releases as |release|}}Mac OS X {{release.version}}: {{release.name}} {{/each}}'),
releases: A([
{ version: '10.7',
@@ -451,9 +451,7 @@ QUnit.test('should pass content as context when using {{#each}} helper [DEPRECAT
])
});
- expectDeprecation(function() {
- runAppend(view);
- }, 'Using the context switching form of {{each}} is deprecated. Please use the keyword form (`{{#each items as |item|}}`) instead.');
+ runAppend(view);
equal(view.$().text(), 'Mac OS X 10.7: Lion Mac OS X 10.6: Snow Leopard Mac OS X 10.5: Leopard ', 'prints each item in sequence');
});
diff --git a/packages/ember-htmlbars/tests/helpers/each_test.js b/packages/ember-htmlbars/tests/helpers/each_test.js
index 4d72a8a82a4..83a99c38d7d 100644
--- a/packages/ember-htmlbars/tests/helpers/each_test.js
+++ b/packages/ember-htmlbars/tests/helpers/each_test.js
@@ -12,7 +12,6 @@ import { set } from 'ember-metal/property_set';
import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
import compile from 'ember-template-compiler/system/compile';
-import { deprecation as eachDeprecation } from 'ember-htmlbars/helpers/each';
import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils';
import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection';
@@ -24,70 +23,10 @@ var people, view, registry, container;
var template, templateMyView, MyView, MyEmptyView, templateMyEmptyView;
var originalViewKeyword;
-// This function lets us write {{#EACH|people|p}} {{p}} {{/each}}
-// and generate:
-//
-// - {{#each p in people}} (legacy)
-// - {{#each people as |p|}} (legacy)
-function makeReplacer(useBlockParams) {
- return function(_, matchString) {
- var values = matchString.split('|');
- if (values.length === 1) { return 'each'; }
-
- var arr = useBlockParams ?
- ['each', values[1], 'as', '|' + values[2] + '|'] :
- ['each', values[2], 'in', values[1]];
-
- var options = values[3];
- if (options) {
- if (useBlockParams) {
- arr.splice(2, 0, options);
- } else {
- arr.push(options);
- }
- }
-
- return arr.join(' ');
- };
-}
-
-var parseEachReplacerBlockParam = makeReplacer(true);
-var parseEachReplacerNonBlockParam = makeReplacer(false);
-
-var EACH_REGEX = /(EACH[^\}]*)/g;
-
-function parseEach(str, useBlockParams) {
- return str.replace(EACH_REGEX, useBlockParams ? parseEachReplacerBlockParam : parseEachReplacerNonBlockParam);
-}
-
-QUnit.module('parseEach test helper');
-
-QUnit.test('block param syntax substitution', function() {
- equal(parseEach('{{#EACH|people|p}}p people{{/EACH}}', true), '{{#each people as |p|}}p people{{/each}}');
- equal(parseEach('{{#EACH|people|p|a=\'b\' c=\'d\'}}p people{{/EACH}}', true), '{{#each people a=\'b\' c=\'d\' as |p|}}p people{{/each}}');
-});
-
-QUnit.test('non-block param syntax substitution', function() {
- equal(parseEach('{{#EACH|people|p}}p people{{/EACH}}', false), '{{#each p in people}}p people{{/each}}');
- equal(parseEach('{{#EACH|people|p|a=\'b\' c=\'d\'}}p people{{/EACH}}', false), '{{#each p in people a=\'b\' c=\'d\'}}p people{{/each}}');
-});
-
-function templateFor(templateString, useBlockParams) {
- var parsedTemplateString = parseEach(templateString, useBlockParams);
- var template;
-
- if (!useBlockParams) {
- expectDeprecation(/use the block param form/);
- }
- template = compile(parsedTemplateString);
-
- return template;
-}
-
var originalLookup = Ember.lookup;
var lookup;
-QUnit.module('the #each helper [DEPRECATED]', {
+QUnit.module('the #each helper', {
setup() {
Ember.lookup = lookup = { Ember: Ember };
@@ -95,7 +34,7 @@ QUnit.module('the #each helper [DEPRECATED]', {
registerAstPlugin(TransformEachIntoCollection);
- template = compile('{{#each view.people}}{{name}}{{/each}}');
+ template = compile('{{#each view.people as |person|}}{{person.name}}{{/each}}');
people = A([{ name: 'Steve Holt' }, { name: 'Annabelle' }]);
registry = new Registry();
@@ -111,9 +50,7 @@ QUnit.module('the #each helper [DEPRECATED]', {
});
templateMyView = compile('{{name}}');
- lookup.MyView = MyView = EmberView.extend({
- template: templateMyView
- });
+ lookup.MyView = MyView = EmberView.extend({ template: templateMyView });
registry.register('view:my-view', MyView);
templateMyEmptyView = compile('I\'m empty');
@@ -122,9 +59,7 @@ QUnit.module('the #each helper [DEPRECATED]', {
});
registry.register('view:my-empty-view', MyEmptyView);
- expectDeprecation(function() {
- runAppend(view);
- }, eachDeprecation);
+ runAppend(view);
},
teardown() {
@@ -165,34 +100,6 @@ QUnit.test('it updates the view if an item is added', function() {
assertHTML(view, 'Steve HoltAnnabelleTom Dale');
});
-if (typeof Handlebars === 'object') {
- QUnit.test('should be able to use standard Handlebars #each helper', function() {
- runDestroy(view);
-
- view = EmberView.create({
- context: { items: ['a', 'b', 'c'] },
- template: Handlebars.compile('{{#each items}}{{this}}{{/each}}')
- });
-
- runAppend(view);
-
- equal(view.$().html(), 'abc');
- });
-}
-
-QUnit.test('it allows you to access the current context using {{this}}', function() {
- runDestroy(view);
-
- view = EmberView.create({
- template: compile('{{#each view.people}}{{this}}{{/each}}'),
- people: A(['Black Francis', 'Joey Santiago', 'Kim Deal', 'David Lovering'])
- });
-
- runAppend(view);
-
- assertHTML(view, 'Black FrancisJoey SantiagoKim DealDavid Lovering');
-});
-
QUnit.test('it updates the view if an item is removed', function() {
run(function() {
people.removeAt(0);
@@ -347,12 +254,13 @@ QUnit.test('it supports {{itemView=}}', function() {
template: compile('itemView:{{name}}')
});
- runDestroy(view);
- view = EmberView.create({
- template: compile('{{each view.people itemView="anItemView"}}'),
- people: people,
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people itemView="anItemView"}}'),
+ people: people,
+ container: container
+ });
+ }, /Using 'itemView' with '{{each}}'/);
registry.register('view:anItemView', itemView);
@@ -361,18 +269,18 @@ QUnit.test('it supports {{itemView=}}', function() {
assertText(view, 'itemView:Steve HoltitemView:Annabelle');
});
-
QUnit.test('it defers all normalization of itemView names to the resolver', function() {
var itemView = EmberView.extend({
template: compile('itemView:{{name}}')
});
- runDestroy(view);
- view = EmberView.create({
- template: compile('{{each view.people itemView="an-item-view"}}'),
- people: people,
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people itemView="an-item-view"}}'),
+ people: people,
+ container: container
+ });
+ }, /Using 'itemView' with '{{each}}'/);
registry.register('view:an-item-view', itemView);
runAppend(view);
@@ -381,12 +289,13 @@ QUnit.test('it defers all normalization of itemView names to the resolver', func
});
QUnit.test('it supports {{itemViewClass=}} with global (DEPRECATED)', function() {
- runDestroy(view);
- view = EmberView.create({
- template: compile('{{each view.people itemViewClass=MyView}}'),
- people: people,
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people itemViewClass=MyView}}'),
+ people: people,
+ container: container
+ });
+ }, /Using 'itemViewClass' with '{{each}}'/);
var deprecation = /Global lookup of MyView from a Handlebars template is deprecated/;
@@ -398,12 +307,13 @@ QUnit.test('it supports {{itemViewClass=}} with global (DEPRECATED)', function()
});
QUnit.test('it supports {{itemViewClass=}} via container', function() {
- runDestroy(view);
- view = EmberView.create({
- container: container,
- template: compile('{{each view.people itemViewClass="my-view"}}'),
- people: people
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ container: container,
+ template: compile('{{each view.people itemViewClass="my-view"}}'),
+ people: people
+ });
+ }, /Using 'itemViewClass' with '{{each}}'/);
runAppend(view);
@@ -411,12 +321,13 @@ QUnit.test('it supports {{itemViewClass=}} via container', function() {
});
QUnit.test('it supports {{itemViewClass=}} with each view tagName (DEPRECATED)', function() {
- runDestroy(view);
- view = EmberView.create({
- template: compile('{{each view.people itemViewClass=MyView tagName="ul"}}'),
- people: people,
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people itemViewClass=MyView tagName="ul"}}'),
+ people: people,
+ container: container
+ });
+ }, /Using 'itemViewClass' with '{{each}}'/);
runAppend(view);
equal(view.$('ul').length, 1, 'rendered ul tag');
@@ -425,16 +336,17 @@ QUnit.test('it supports {{itemViewClass=}} with each view tagName (DEPRECATED)',
});
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: compile('
{{#each view.people itemViewClass="li-view" as |item|}}{{item.name}}{{/each}}
'),
- people: people,
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{#each view.people itemViewClass="li-view" as |item|}}{{item.name}}{{/each}}
'),
+ people: people,
+ container: container
+ });
+ }, /Using 'itemViewClass' with '{{each}}'/);
runAppend(view);
@@ -444,18 +356,18 @@ QUnit.test('it supports {{itemViewClass=}} with tagName in itemViewClass (DEPREC
});
QUnit.test('it supports {{itemViewClass=}} with {{else}} block (DEPRECATED)', function() {
- runDestroy(view);
-
- view = EmberView.create({
- template: compile(`
- {{~#each view.people itemViewClass="my-view" as |item|~}}
- {{item.name}}
- {{~else~}}
- No records!
- {{~/each}}`),
- people: A(),
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile(`
+ {{~#each view.people itemViewClass="my-view" as |item|~}}
+ {{item.name}}
+ {{~else~}}
+ No records!
+ {{~/each}}`),
+ people: A(),
+ container: container
+ });
+ }, /Using 'itemViewClass' with '{{each}}'/);
runAppend(view);
@@ -467,13 +379,13 @@ QUnit.test('it supports {{emptyView=}}', function() {
template: compile('emptyView:sad panda')
});
- runDestroy(view);
-
- view = EmberView.create({
- template: compile('{{each view.people emptyView="anEmptyView"}}'),
- people: A(),
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people emptyView="anEmptyView"}}'),
+ people: A(),
+ container: container
+ });
+ }, /Using 'emptyView' with '{{each}}'/);
registry.register('view:anEmptyView', emptyView);
@@ -487,13 +399,13 @@ QUnit.test('it defers all normalization of emptyView names to the resolver', fun
template: compile('emptyView:sad panda')
});
- runDestroy(view);
-
- view = EmberView.create({
- template: compile('{{each view.people emptyView="an-empty-view"}}'),
- people: A(),
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people emptyView="an-empty-view"}}'),
+ people: A(),
+ container: container
+ });
+ }, /Using 'emptyView' with '{{each}}'/);
registry.register('view:an-empty-view', emptyView);
@@ -503,13 +415,13 @@ QUnit.test('it defers all normalization of emptyView names to the resolver', fun
});
QUnit.test('it supports {{emptyViewClass=}} with global (DEPRECATED)', function() {
- runDestroy(view);
-
- view = EmberView.create({
- template: compile('{{each view.people emptyViewClass=MyEmptyView}}'),
- people: A(),
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people emptyViewClass=MyEmptyView}}'),
+ people: A(),
+ container: container
+ });
+ }, /Using 'emptyViewClass' with '{{each}}'/);
var deprecation = /Global lookup of MyEmptyView from a Handlebars template is deprecated/;
@@ -521,13 +433,13 @@ QUnit.test('it supports {{emptyViewClass=}} with global (DEPRECATED)', function(
});
QUnit.test('it supports {{emptyViewClass=}} via container', function() {
- runDestroy(view);
-
- view = EmberView.create({
- container: container,
- template: compile('{{each view.people emptyViewClass="my-empty-view"}}'),
- people: A()
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ container: container,
+ template: compile('{{each view.people emptyViewClass="my-empty-view"}}'),
+ people: A()
+ });
+ }, /Using 'emptyViewClass' with '{{each}}'/);
runAppend(view);
@@ -535,13 +447,13 @@ QUnit.test('it supports {{emptyViewClass=}} via container', function() {
});
QUnit.test('it supports {{emptyViewClass=}} with tagName (DEPRECATED)', function() {
- runDestroy(view);
-
- view = EmberView.create({
- template: compile('{{each view.people emptyViewClass=MyEmptyView tagName="b"}}'),
- people: A(),
- container: container
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ template: compile('{{each view.people emptyViewClass=MyEmptyView tagName="b"}}'),
+ people: A(),
+ container: container
+ });
+ }, /Using 'emptyViewClass' with '{{each}}'/);
runAppend(view);
@@ -550,13 +462,13 @@ QUnit.test('it supports {{emptyViewClass=}} with tagName (DEPRECATED)', function
});
QUnit.test('it supports {{emptyViewClass=}} with in format', function() {
- runDestroy(view);
-
- view = EmberView.create({
- container: container,
- template: compile('{{each person in view.people emptyViewClass="my-empty-view"}}'),
- people: A()
- });
+ expectDeprecation(() => {
+ view = EmberView.create({
+ container: container,
+ template: compile('{{each person in view.people emptyViewClass="my-empty-view"}}'),
+ people: A()
+ });
+ }, /Using 'emptyViewClass' with '{{each}}'/);
runAppend(view);
@@ -564,9 +476,8 @@ QUnit.test('it supports {{emptyViewClass=}} with in format', function() {
});
QUnit.test('it uses {{else}} when replacing model with an empty array', function() {
- runDestroy(view);
view = EmberView.create({
- template: compile('{{#each view.items}}{{this}}{{else}}Nothing{{/each}}'),
+ template: compile('{{#each view.items as |item|}}{{item}}{{else}}Nothing{{/each}}'),
items: A(['one', 'two'])
});
@@ -583,9 +494,8 @@ QUnit.test('it uses {{else}} when replacing model with an empty array', function
QUnit.test('it uses {{else}} when removing all items in an array', function() {
var items = A(['one', 'two']);
- runDestroy(view);
view = EmberView.create({
- template: compile('{{#each view.items}}{{this}}{{else}}Nothing{{/each}}'),
+ template: compile('{{#each view.items as |item|}}{{item}}{{else}}Nothing{{/each}}'),
items
});
@@ -603,9 +513,8 @@ QUnit.test('it uses {{else}} when removing all items in an array', function() {
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}}'),
+ template: compile('{{#each view.items as |item|}}{{item}}{{else}}Nothing{{/each}}'),
items
});
@@ -635,190 +544,135 @@ QUnit.test('it can move to and from {{else}} properly when the backing array gai
assertHTML(view, 'Nothing');
});
-QUnit.test('views inside #each preserve the new context [DEPRECATED]', function() {
- runDestroy(view);
+QUnit.module('{{each bar as |foo|}}', {
+ setup() {
+ registry = new Registry();
+ container = registry.container();
- var controller = A([{ name: 'Adam' }, { name: 'Steve' }]);
+ registry.register('view:toplevel', EmberView.extend());
+ registry.register('view:-legacy-each', LegacyEachView);
+ },
+ teardown() {
+ runDestroy(container);
+ runDestroy(view);
+ container = view = null;
+ }
+});
+QUnit.test('#each accepts a name binding', function() {
view = EmberView.create({
- container: container,
- controller: controller,
- template: compile('{{#each controller}}{{#view}}{{name}}{{/view}}{{/each}}')
+ template: compile('{{#each view.items as |item|}}{{view.title}} {{item}}{{/each}}'),
+ title: 'My Cool Each Test',
+ items: A([1, 2])
});
+ runAppend(view);
- expectDeprecation(function() {
- runAppend(view);
- }, eachDeprecation);
-
- equal(view.$().text(), 'AdamSteve');
+ equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
});
-function testEachWithItem(moduleName, useBlockParams) {
- QUnit.module(moduleName, {
- setup() {
- registry = new Registry();
- container = registry.container();
-
- registry.register('view:toplevel', EmberView.extend());
- registry.register('view:-legacy-each', LegacyEachView);
- },
- teardown() {
- runDestroy(container);
- runDestroy(view);
- container = view = null;
- }
+QUnit.test('#each accepts a name binding and does not change the context', function() {
+ var controller = EmberController.create({
+ name: 'bob the controller'
});
-
- QUnit.test('#each accepts a name binding', function() {
- view = EmberView.create({
- template: templateFor('{{#EACH|view.items|item}}{{view.title}} {{item}}{{/each}}', useBlockParams),
- title: 'My Cool Each Test',
- items: A([1, 2])
- });
-
- runAppend(view);
-
- equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
+ var obj = EmberObject.create({
+ name: 'henry the item'
});
- QUnit.test('#each accepts a name binding and does not change the context', function() {
- var controller = EmberController.create({
- name: 'bob the controller'
- });
- var obj = EmberObject.create({
- name: 'henry the item'
- });
-
- view = EmberView.create({
- template: templateFor('{{#EACH|view.items|item}}{{name}}{{/each}}', useBlockParams),
- title: 'My Cool Each Test',
- items: A([obj]),
- controller: controller
- });
-
- runAppend(view);
-
- equal(view.$().text(), 'bob the controller');
+ view = EmberView.create({
+ template: compile('{{#each view.items as |item|}}{{name}}{{/each}}'),
+ title: 'My Cool Each Test',
+ items: A([obj]),
+ controller: controller
});
+ runAppend(view);
- QUnit.test('#each accepts a name binding and can display child properties', function() {
- view = EmberView.create({
- template: templateFor('{{#EACH|view.items|item}}{{view.title}} {{item.name}}{{/each}}', useBlockParams),
- title: 'My Cool Each Test',
- items: A([{ name: 1 }, { name: 2 }])
- });
-
- runAppend(view);
+ equal(view.$().text(), 'bob the controller');
+});
- equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
+QUnit.test('#each accepts a name binding and can display child properties', function() {
+ view = EmberView.create({
+ template: compile('{{#each view.items as |item|}}{{view.title}} {{item.name}}{{/each}}'),
+ title: 'My Cool Each Test',
+ items: A([{ name: 1 }, { name: 2 }])
});
- QUnit.test('#each accepts \'this\' as the right hand side', function() {
- view = EmberView.create({
- template: templateFor('{{#EACH|this|item}}{{view.title}} {{item.name}}{{/each}}', useBlockParams),
- title: 'My Cool Each Test',
- controller: A([{ name: 1 }, { name: 2 }])
- });
+ runAppend(view);
- runAppend(view);
+ equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
+});
- equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
+QUnit.test('#each accepts \'this\' as the right hand side', function() {
+ view = EmberView.create({
+ template: compile('{{#each this as |item|}}{{view.title}} {{item.name}}{{/each}}'),
+ title: 'My Cool Each Test',
+ controller: A([{ name: 1 }, { name: 2 }])
});
- if (!useBlockParams) {
- QUnit.test('views inside #each preserve the new context [DEPRECATED]', function() {
- var controller = A([{ name: 'Adam' }, { name: 'Steve' }]);
-
- view = EmberView.create({
- container: container,
- controller: controller,
- template: compile('{{#each controller}}{{#view}}{{name}}{{/view}}{{/each}}', useBlockParams)
- });
-
- expectDeprecation(function() {
- runAppend(view);
- }, eachDeprecation);
-
- equal(view.$().text(), 'AdamSteve');
- });
- }
-
- QUnit.test('it doesn\'t assert when the morph tags have the same parent', function() {
- view = EmberView.create({
- controller: A(['Cyril', 'David']),
- template: templateFor('{{#EACH|this|name}}{{name}} |
{{/each}}
', useBlockParams)
- });
+ runAppend(view);
- runAppend(view);
+ equal(view.$().text(), 'My Cool Each Test 1My Cool Each Test 2');
+});
- ok(true, 'No assertion from valid template');
+QUnit.test('it doesn\'t assert when the morph tags have the same parent', function() {
+ view = EmberView.create({
+ controller: A(['Cyril', 'David']),
+ template: compile('{{#each this as |name|}}{{name}} |
{{/each}}
')
});
- QUnit.test('locals in stable loops update when the list is updated', function() {
- expect(3);
-
- var list = [{ key: 'adam', name: 'Adam' }, { key: 'steve', name: 'Steve' }];
- view = EmberView.create({
- queries: list,
- template: compile('{{#each view.queries key="key" as |query|}}{{query.name}}{{/each}}', true)
- });
- runAppend(view);
- equal(view.$().text(), 'AdamSteve');
+ runAppend(view);
- run(function() {
- list.unshift({ key: 'bob', name: 'Bob' });
- view.set('queries', list);
- view.notifyPropertyChange('queries');
- });
+ ok(true, 'No assertion from valid template');
+});
- equal(view.$().text(), 'BobAdamSteve');
+QUnit.test('locals in stable loops update when the list is updated', function() {
+ expect(3);
- run(function() {
- view.set('queries', [{ key: 'bob', name: 'Bob' }, { key: 'steve', name: 'Steve' }]);
- view.notifyPropertyChange('queries');
- });
+ var list = [{ key: 'adam', name: 'Adam' }, { key: 'steve', name: 'Steve' }];
+ view = EmberView.create({
+ queries: list,
+ template: compile('{{#each view.queries key="key" as |query|}}{{query.name}}{{/each}}', true)
+ });
+ runAppend(view);
+ equal(view.$().text(), 'AdamSteve');
- equal(view.$().text(), 'BobSteve');
+ run(function() {
+ list.unshift({ key: 'bob', name: 'Bob' });
+ view.set('queries', list);
+ view.notifyPropertyChange('queries');
});
- if (useBlockParams) {
- QUnit.test('the index is passed as the second parameter to #each blocks', function() {
- expect(3);
+ equal(view.$().text(), 'BobAdamSteve');
- var adam = { name: 'Adam' };
- view = EmberView.create({
- controller: A([adam, { name: 'Steve' }]),
- template: templateFor('{{#each this as |person index|}}{{index}}. {{person.name}}{{/each}}', true)
- });
- runAppend(view);
- equal(view.$().text(), '0. Adam1. Steve');
+ run(function() {
+ view.set('queries', [{ key: 'bob', name: 'Bob' }, { key: 'steve', name: 'Steve' }]);
+ view.notifyPropertyChange('queries');
+ });
- run(function() {
- view.get('controller').unshiftObject({ name: 'Bob' });
- });
- equal(view.$().text(), '0. Bob1. Adam2. Steve');
+ equal(view.$().text(), 'BobSteve');
+});
- run(function() {
- view.get('controller').removeObject(adam);
- });
- equal(view.$().text(), '0. Bob1. Steve');
- });
- }
-}
+QUnit.test('the index is passed as the second parameter to #each blocks', function() {
+ expect(3);
-QUnit.test('context switching deprecation is printed when no items are present', function() {
- runDestroy(view);
+ var adam = { name: 'Adam' };
view = EmberView.create({
- template: compile('{{#each view.items}}{{this}}{{else}}Nothing{{/each}}')
+ controller: A([adam, { name: 'Steve' }]),
+ template: compile('{{#each this as |person index|}}{{index}}. {{person.name}}{{/each}}')
});
+ runAppend(view);
+ equal(view.$().text(), '0. Adam1. Steve');
- expectDeprecation(function() {
- runAppend(view);
- }, /Using the context switching form of \{\{each\}\} is deprecated/);
+ run(function() {
+ view.get('controller').unshiftObject({ name: 'Bob' });
+ });
+ equal(view.$().text(), '0. Bob1. Adam2. Steve');
- assertHTML(view, 'Nothing');
+ run(function() {
+ view.get('controller').removeObject(adam);
+ });
+ equal(view.$().text(), '0. Bob1. Steve');
});
QUnit.test('a string key can be used with {{each}}', function() {
@@ -977,4 +831,3 @@ QUnit.test('pushing a new duplicate key will trigger a useful error (temporary u
);
});
-testEachWithItem('{{#each bar as |foo|}}', true);
diff --git a/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js b/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js
index c54acf8c1c3..7d4384626cd 100644
--- a/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js
+++ b/packages/ember-routing-htmlbars/tests/helpers/element_action_test.js
@@ -14,7 +14,6 @@ import EmberComponent from 'ember-views/views/component';
import jQuery from 'ember-views/system/jquery';
import { ActionHelper } from 'ember-routing-htmlbars/keywords/element-action';
-import { deprecation as eachDeprecation } from 'ember-htmlbars/helpers/each';
import { registerKeyword, resetKeyword } from 'ember-htmlbars/tests/utils';
import viewKeyword from 'ember-htmlbars/keywords/view';
@@ -779,13 +778,13 @@ QUnit.test('a quoteless parameter should allow dynamic lookup of the actionName'
});
QUnit.test('a quoteless parameter should lookup actionName in context [DEPRECATED]', function() {
- expect(5);
+ expect(4);
var lastAction;
var actionOrder = [];
ignoreDeprecation(function() {
view = EmberView.create({
- template: compile('{{#each allactions}}{{title}}{{/each}}')
+ template: compile('{{#each allactions as |allacation|}}{{allacation.title}}{{/each}}')
});
});
@@ -809,12 +808,10 @@ QUnit.test('a quoteless parameter should lookup actionName in context [DEPRECATE
}
}).create();
- expectDeprecation(function() {
- run(function() {
- view.set('controller', controller);
- view.appendTo('#qunit-fixture');
- });
- }, eachDeprecation);
+ run(function() {
+ view.set('controller', controller);
+ view.appendTo('#qunit-fixture');
+ });
var testBoundAction = function(propertyValue) {
run(function() {