From 9864fcb9e986473f78d4fdb527eab51e4fc438e4 Mon Sep 17 00:00:00 2001 From: Marten Schilstra Date: Thu, 16 Jul 2015 21:22:44 +0200 Subject: [PATCH] [CLEANUP beta] Remove `{{each model}}` (single arg each). --- .../ember-htmlbars/tests/helpers/each_test.js | 63 ------------------- packages/ember-template-compiler/lib/main.js | 2 - .../lib/plugins/transform-single-arg-each.js | 22 ------- 3 files changed, 87 deletions(-) delete mode 100644 packages/ember-template-compiler/lib/plugins/transform-single-arg-each.js diff --git a/packages/ember-htmlbars/tests/helpers/each_test.js b/packages/ember-htmlbars/tests/helpers/each_test.js index 2e1ace08319..40f5711860c 100644 --- a/packages/ember-htmlbars/tests/helpers/each_test.js +++ b/packages/ember-htmlbars/tests/helpers/each_test.js @@ -640,37 +640,6 @@ QUnit.test('views inside #each preserve the new context [DEPRECATED]', function( equal(view.$().text(), 'AdamSteve'); }); -QUnit.test('single-arg each defaults to current context [DEPRECATED]', function() { - runDestroy(view); - - view = EmberView.create({ - context: A([{ name: 'Adam' }, { name: 'Steve' }]), - template: compile('{{#each}}{{name}}{{/each}}') - }); - - expectDeprecation(function() { - runAppend(view); - }, eachDeprecation); - - equal(view.$().text(), 'AdamSteve'); -}); - -QUnit.test('single-arg each will iterate over controller if present [DEPRECATED]', function() { - runDestroy(view); - - view = EmberView.create({ - controller: A([{ name: 'Adam' }, { name: 'Steve' }]), - template: compile('{{#each}}{{name}}{{/each}}'), - container: container - }); - - expectDeprecation(function() { - runAppend(view); - }, eachDeprecation); - - equal(view.$().text(), 'AdamSteve'); -}); - function testEachWithItem(moduleName, useBlockParams) { QUnit.module(moduleName, { setup() { @@ -800,38 +769,6 @@ function testEachWithItem(moduleName, useBlockParams) { equal(view.$().text(), 'BobSteve'); }); - if (!useBlockParams) { - QUnit.test('{{each}} without arguments [DEPRECATED]', function() { - expect(2); - - view = EmberView.create({ - controller: A([{ name: 'Adam' }, { name: 'Steve' }]), - template: compile('{{#each}}{{name}}{{/each}}') - }); - - expectDeprecation(function() { - runAppend(view); - }, eachDeprecation); - - equal(view.$().text(), 'AdamSteve'); - }); - - QUnit.test('{{each this}} without keyword [DEPRECATED]', function() { - expect(2); - - view = EmberView.create({ - controller: A([{ name: 'Adam' }, { name: 'Steve' }]), - template: compile('{{#each this}}{{name}}{{/each}}') - }); - - expectDeprecation(function() { - runAppend(view); - }, eachDeprecation); - - equal(view.$().text(), 'AdamSteve'); - }); - } - if (useBlockParams) { QUnit.test('the index is passed as the second parameter to #each blocks', function() { expect(3); diff --git a/packages/ember-template-compiler/lib/main.js b/packages/ember-template-compiler/lib/main.js index 8c9d918963a..b7c4f714ce3 100644 --- a/packages/ember-template-compiler/lib/main.js +++ b/packages/ember-template-compiler/lib/main.js @@ -6,7 +6,6 @@ import { registerPlugin } from 'ember-template-compiler/plugins'; import TransformWithAsToHash from 'ember-template-compiler/plugins/transform-with-as-to-hash'; import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; -import TransformSingleArgEach from 'ember-template-compiler/plugins/transform-single-arg-each'; import TransformOldBindingSyntax from 'ember-template-compiler/plugins/transform-old-binding-syntax'; import TransformOldClassBindingSyntax from 'ember-template-compiler/plugins/transform-old-class-binding-syntax'; import TransformItemClass from 'ember-template-compiler/plugins/transform-item-class'; @@ -22,7 +21,6 @@ import DeprecateViewHelper from 'ember-template-compiler/plugins/deprecate-view- import 'ember-template-compiler/compat'; registerPlugin('ast', TransformWithAsToHash); -registerPlugin('ast', TransformSingleArgEach); registerPlugin('ast', TransformEachIntoCollection); registerPlugin('ast', TransformOldBindingSyntax); registerPlugin('ast', TransformOldClassBindingSyntax); diff --git a/packages/ember-template-compiler/lib/plugins/transform-single-arg-each.js b/packages/ember-template-compiler/lib/plugins/transform-single-arg-each.js deleted file mode 100644 index d062f3ef4fa..00000000000 --- a/packages/ember-template-compiler/lib/plugins/transform-single-arg-each.js +++ /dev/null @@ -1,22 +0,0 @@ -export default function TransformSingleArgEach() { - this.syntax = null; -} - -TransformSingleArgEach.prototype.transform = function TransformSingleArgEach_transform(ast) { - var b = this.syntax.builders; - var walker = new this.syntax.Walker(); - - walker.visit(ast, function(node) { - if (!validate(node)) { return; } - - node.params.push(b.path('this')); - }); - - return ast; -}; - -function validate(node) { - return (node.type === 'BlockStatement' || node.type === 'MustacheStatement') && - node.path.original === 'each' && - node.params.length === 0; -}