diff --git a/packages/ember-htmlbars/tests/compat/controller_keyword_test.js b/packages/ember-htmlbars/tests/compat/controller_keyword_test.js index 228629aedad..ebac7a945e3 100644 --- a/packages/ember-htmlbars/tests/compat/controller_keyword_test.js +++ b/packages/ember-htmlbars/tests/compat/controller_keyword_test.js @@ -2,14 +2,24 @@ import EmberComponent from 'ember-views/views/component'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import compile from 'ember-template-compiler/system/compile'; +import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; +import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; +import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; + let component; QUnit.module('ember-htmlbars: compat - controller keyword (use as a path)', { setup() { + registerAstPlugin(TransformEachIntoCollection); + registerAstPlugin(DeprecateViewAndControllerPaths); + component = null; }, teardown() { runDestroy(component); + + removeAstPlugin(TransformEachIntoCollection); + removeAstPlugin(DeprecateViewAndControllerPaths); } }); diff --git a/packages/ember-htmlbars/tests/compat/view_helper_test.js b/packages/ember-htmlbars/tests/compat/view_helper_test.js index 0b60d2c2e53..18b969f6c75 100644 --- a/packages/ember-htmlbars/tests/compat/view_helper_test.js +++ b/packages/ember-htmlbars/tests/compat/view_helper_test.js @@ -5,16 +5,22 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import compile from 'ember-template-compiler/system/compile'; import Registry from 'container/registry'; +import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; +import DeprecateViewHelper from 'ember-template-compiler/plugins/deprecate-view-helper'; + let component, registry, container; QUnit.module('ember-htmlbars: compat - view helper', { setup() { + registerAstPlugin(DeprecateViewHelper); + registry = new Registry(); container = registry.container(); }, teardown() { runDestroy(component); runDestroy(container); + removeAstPlugin(DeprecateViewHelper); registry = container = component = null; } }); diff --git a/packages/ember-htmlbars/tests/compat/view_keyword_test.js b/packages/ember-htmlbars/tests/compat/view_keyword_test.js index 447ba08708d..8e745706043 100644 --- a/packages/ember-htmlbars/tests/compat/view_keyword_test.js +++ b/packages/ember-htmlbars/tests/compat/view_keyword_test.js @@ -2,14 +2,19 @@ import EmberComponent from 'ember-views/views/component'; import { runAppend, runDestroy } from 'ember-runtime/tests/utils'; import compile from 'ember-template-compiler/system/compile'; +import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; +import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; + let component; QUnit.module('ember-htmlbars: compat - view keyword (use as a path)', { setup() { + registerAstPlugin(DeprecateViewAndControllerPaths); component = null; }, teardown() { runDestroy(component); + removeAstPlugin(DeprecateViewAndControllerPaths); } }); diff --git a/packages/ember-htmlbars/tests/helpers/each_test.js b/packages/ember-htmlbars/tests/helpers/each_test.js index 40f5711860c..e4a0c57e568 100644 --- a/packages/ember-htmlbars/tests/helpers/each_test.js +++ b/packages/ember-htmlbars/tests/helpers/each_test.js @@ -14,6 +14,9 @@ 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'; + var people, view, registry, container; var template, templateMyView, MyView, MyEmptyView, templateMyEmptyView; @@ -85,6 +88,8 @@ QUnit.module('the #each helper [DEPRECATED]', { setup() { Ember.lookup = lookup = { Ember: Ember }; + registerAstPlugin(TransformEachIntoCollection); + template = compile('{{#each view.people}}{{name}}{{/each}}'); people = A([{ name: 'Steve Holt' }, { name: 'Annabelle' }]); @@ -123,6 +128,8 @@ QUnit.module('the #each helper [DEPRECATED]', { registry = container = view = null; Ember.lookup = originalLookup; + + removeAstPlugin(TransformEachIntoCollection); } }); diff --git a/packages/ember-htmlbars/tests/utils.js b/packages/ember-htmlbars/tests/utils.js new file mode 100644 index 00000000000..2d55ffed81e --- /dev/null +++ b/packages/ember-htmlbars/tests/utils.js @@ -0,0 +1,15 @@ +import plugins, { registerPlugin } from 'ember-template-compiler/plugins'; + +function registerAstPlugin(plugin) { + registerPlugin('ast', plugin); +} + +function removeAstPlugin(plugin) { + const index = plugins['ast'].indexOf(plugin); + plugins['ast'].splice(index, 1); +} + +export { + registerAstPlugin, + removeAstPlugin +}; diff --git a/packages/ember-template-compiler/lib/main.js b/packages/ember-template-compiler/lib/main.js index 6aa4430504b..b9ea7d55ff9 100644 --- a/packages/ember-template-compiler/lib/main.js +++ b/packages/ember-template-compiler/lib/main.js @@ -4,7 +4,6 @@ import compile from 'ember-template-compiler/system/compile'; import template from 'ember-template-compiler/system/template'; import { registerPlugin } from 'ember-template-compiler/plugins'; -import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; 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'; @@ -12,14 +11,14 @@ import TransformComponentAttrsIntoMut from 'ember-template-compiler/plugins/tran import TransformComponentCurlyToReadonly from 'ember-template-compiler/plugins/transform-component-curly-to-readonly'; import TransformAngleBracketComponents from 'ember-template-compiler/plugins/transform-angle-bracket-components'; import TransformInputOnToOnEvent from 'ember-template-compiler/plugins/transform-input-on-to-onEvent'; -import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; import TransformTopLevelComponents from 'ember-template-compiler/plugins/transform-top-level-components'; +import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; +import DeprecateViewAndControllerPaths from 'ember-template-compiler/plugins/deprecate-view-and-controller-paths'; import DeprecateViewHelper from 'ember-template-compiler/plugins/deprecate-view-helper'; // used for adding Ember.Handlebars.compile for backwards compat import 'ember-template-compiler/compat'; -registerPlugin('ast', TransformEachIntoCollection); registerPlugin('ast', TransformOldBindingSyntax); registerPlugin('ast', TransformOldClassBindingSyntax); registerPlugin('ast', TransformItemClass); @@ -28,8 +27,13 @@ registerPlugin('ast', TransformComponentCurlyToReadonly); registerPlugin('ast', TransformAngleBracketComponents); registerPlugin('ast', TransformInputOnToOnEvent); registerPlugin('ast', TransformTopLevelComponents); -registerPlugin('ast', DeprecateViewAndControllerPaths); -registerPlugin('ast', DeprecateViewHelper); + +if (_Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { + registerPlugin('ast', TransformEachIntoCollection); + registerPlugin('ast', DeprecateViewAndControllerPaths); + registerPlugin('ast', DeprecateViewHelper); +} + export { _Ember, diff --git a/packages/ember-template-compiler/tests/plugins/transform-each-into-collection-test.js b/packages/ember-template-compiler/tests/plugins/transform-each-into-collection-test.js index 69934f41908..e14ba782700 100644 --- a/packages/ember-template-compiler/tests/plugins/transform-each-into-collection-test.js +++ b/packages/ember-template-compiler/tests/plugins/transform-each-into-collection-test.js @@ -1,6 +1,16 @@ import { compile } from 'ember-template-compiler'; -QUnit.module('ember-template-compiler: transform-each-into-collection'); +import { registerAstPlugin, removeAstPlugin } from 'ember-htmlbars/tests/utils'; +import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; + +QUnit.module('ember-template-compiler: transform-each-into-collection', { + setup() { + registerAstPlugin(TransformEachIntoCollection); + }, + teardown() { + removeAstPlugin(TransformEachIntoCollection); + } +}); let deprecatedAttrs = ['itemController', 'itemView', 'itemViewClass', 'tagName', 'emptyView', 'emptyViewClass']; diff --git a/packages/ember/tests/controller_test.js b/packages/ember/tests/controller_test.js index e0580b17085..a7951bd53c0 100644 --- a/packages/ember/tests/controller_test.js +++ b/packages/ember/tests/controller_test.js @@ -3,6 +3,9 @@ import Ember from 'ember-metal/core'; import EmberHandlebars from 'ember-htmlbars/compat'; import EmberView from 'ember-views/views/view'; +import plugins, { registerPlugin } from 'ember-template-compiler/plugins'; +import TransformEachIntoCollection from 'ember-template-compiler/plugins/transform-each-into-collection'; + /* In Ember 1.x, controllers subtly affect things like template scope and action targets in exciting and often inscrutable ways. This test @@ -14,8 +17,13 @@ import EmberView from 'ember-views/views/view'; var compile = EmberHandlebars.compile; var App, $fixture, templates; +let originalAstPlugins; + QUnit.module('Template scoping examples', { setup() { + originalAstPlugins = plugins['ast'].slice(0); + registerPlugin('ast', TransformEachIntoCollection); + Ember.run(function() { templates = Ember.TEMPLATES; App = Ember.Application.create({ @@ -42,6 +50,8 @@ QUnit.module('Template scoping examples', { App = null; Ember.TEMPLATES = {}; + + plugins['ast'] = originalAstPlugins; } });