Skip to content

Commit 2c137a1

Browse files
committedJul 25, 2015
Merge pull request #11897 from rwjblue/remove-global-lookup-from-templates
[CLEANUP beta] Remove globals lookup from templates.
2 parents e4f8032 + caa9915 commit 2c137a1

File tree

8 files changed

+3
-322
lines changed

8 files changed

+3
-322
lines changed
 

‎packages/ember-htmlbars/lib/hooks/get-root.js

-14
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,13 @@
33
@submodule ember-htmlbars
44
*/
55

6-
import Ember from 'ember-metal/core';
7-
import { isGlobal } from 'ember-metal/path_cache';
8-
import ProxyStream from 'ember-metal/streams/proxy-stream';
9-
106
export default function getRoot(scope, key) {
117
if (key === 'this') {
128
return [scope.self];
139
} else if (key === 'hasBlock') {
1410
return [!!scope.blocks.default];
1511
} else if (key === 'hasBlockParams') {
1612
return [!!(scope.blocks.default && scope.blocks.default.arity)];
17-
} else if (isGlobal(key) && Ember.lookup[key]) {
18-
return [getGlobal(key)];
1913
} else if (key in scope.locals) {
2014
return [scope.locals[key]];
2115
} else {
@@ -38,11 +32,3 @@ function getKey(scope, key) {
3832
return scope.attrs[key];
3933
}
4034
}
41-
42-
function getGlobal(name) {
43-
Ember.deprecate('Global lookup of ' + name + ' from a Handlebars template is deprecated.', false, { id: 'ember-htmlbars.get-global', until: '3.0.0' });
44-
45-
// This stream should be memoized, but this path is deprecated and
46-
// will be removed soon so it's not worth the trouble.
47-
return new ProxyStream(Ember.lookup[name], name);
48-
}

‎packages/ember-htmlbars/tests/compat/make_bound_helper_test.js

-20
Original file line numberDiff line numberDiff line change
@@ -169,26 +169,6 @@ QUnit.test('bound helpers should support keywords', function() {
169169
equal(view.$().text(), 'AB', 'helper output is correct');
170170
});
171171

172-
QUnit.test('bound helpers should support global paths [DEPRECATED]', function() {
173-
expectDeprecationInHTMLBars();
174-
175-
helper('capitalize', function(value) {
176-
return value.toUpperCase();
177-
});
178-
179-
Ember.lookup = { Text: 'ab' };
180-
181-
view = EmberView.create({
182-
template: compile('{{capitalize Text}}')
183-
});
184-
185-
expectDeprecation(function() {
186-
runAppend(view);
187-
}, /Global lookup of Text from a Handlebars template is deprecated/);
188-
189-
equal(view.$().text(), 'AB', 'helper output is correct');
190-
});
191-
192172
QUnit.test('bound helper should support this keyword', function() {
193173
expectDeprecationInHTMLBars();
194174

‎packages/ember-htmlbars/tests/helpers/collection_test.js

-20
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,6 @@ QUnit.test('Collection views that specify an example view class have their child
8080
ok(firstGrandchild(view).isCustom, 'uses the example view class');
8181
});
8282

83-
QUnit.test('itemViewClass works in the #collection helper with a global (DEPRECATED)', function() {
84-
TemplateTests.ExampleItemView = EmberView.extend({
85-
isAlsoCustom: true
86-
});
87-
88-
view = EmberView.create({
89-
exampleController: ArrayProxy.create({
90-
content: A(['alpha'])
91-
}),
92-
template: compile('{{#collection content=view.exampleController itemViewClass=TemplateTests.ExampleItemView}}beta{{/collection}}')
93-
});
94-
95-
var deprecation = /Global lookup of TemplateTests from a Handlebars template is deprecated/;
96-
expectDeprecation(function() {
97-
runAppend(view);
98-
}, deprecation);
99-
100-
ok(firstGrandchild(view).isAlsoCustom, 'uses the example view class specified in the #collection helper');
101-
});
102-
10383
QUnit.test('itemViewClass works in the #collection helper with a property', function() {
10484
var ExampleItemView = EmberView.extend({
10585
isAlsoCustom: true

‎packages/ember-htmlbars/tests/helpers/each_test.js

+2-38
Original file line numberDiff line numberDiff line change
@@ -288,24 +288,6 @@ QUnit.test('it defers all normalization of itemView names to the resolver', func
288288
assertText(view, 'itemView:Steve HoltitemView:Annabelle');
289289
});
290290

291-
QUnit.test('it supports {{itemViewClass=}} with global (DEPRECATED)', function() {
292-
expectDeprecation(() => {
293-
view = EmberView.create({
294-
template: compile('{{each view.people itemViewClass=MyView}}'),
295-
people: people,
296-
container: container
297-
});
298-
}, /Using 'itemViewClass' with '{{each}}'/);
299-
300-
var deprecation = /Global lookup of MyView from a Handlebars template is deprecated/;
301-
302-
expectDeprecation(function() {
303-
runAppend(view);
304-
}, deprecation);
305-
306-
assertText(view, 'Steve HoltAnnabelle');
307-
});
308-
309291
QUnit.test('it supports {{itemViewClass=}} via container', function() {
310292
expectDeprecation(() => {
311293
view = EmberView.create({
@@ -323,7 +305,7 @@ QUnit.test('it supports {{itemViewClass=}} via container', function() {
323305
QUnit.test('it supports {{itemViewClass=}} with each view tagName (DEPRECATED)', function() {
324306
expectDeprecation(() => {
325307
view = EmberView.create({
326-
template: compile('{{each view.people itemViewClass=MyView tagName="ul"}}'),
308+
template: compile('{{each view.people itemViewClass="my-view" tagName="ul"}}'),
327309
people: people,
328310
container: container
329311
});
@@ -414,24 +396,6 @@ QUnit.test('it defers all normalization of emptyView names to the resolver', fun
414396
assertText(view, 'emptyView:sad panda');
415397
});
416398

417-
QUnit.test('it supports {{emptyViewClass=}} with global (DEPRECATED)', function() {
418-
expectDeprecation(() => {
419-
view = EmberView.create({
420-
template: compile('{{each view.people emptyViewClass=MyEmptyView}}'),
421-
people: A(),
422-
container: container
423-
});
424-
}, /Using 'emptyViewClass' with '{{each}}'/);
425-
426-
var deprecation = /Global lookup of MyEmptyView from a Handlebars template is deprecated/;
427-
428-
expectDeprecation(function() {
429-
runAppend(view);
430-
}, deprecation);
431-
432-
assertText(view, 'I\'m empty');
433-
});
434-
435399
QUnit.test('it supports {{emptyViewClass=}} via container', function() {
436400
expectDeprecation(() => {
437401
view = EmberView.create({
@@ -449,7 +413,7 @@ QUnit.test('it supports {{emptyViewClass=}} via container', function() {
449413
QUnit.test('it supports {{emptyViewClass=}} with tagName (DEPRECATED)', function() {
450414
expectDeprecation(() => {
451415
view = EmberView.create({
452-
template: compile('{{each view.people emptyViewClass=MyEmptyView tagName="b"}}'),
416+
template: compile('{{each view.people emptyViewClass="my-empty-view" tagName="b"}}'),
453417
people: A(),
454418
container: container
455419
});

‎packages/ember-htmlbars/tests/helpers/view_test.js

-127
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import ComponentLookup from 'ember-views/component_lookup';
77
import run from 'ember-metal/run_loop';
88
import jQuery from 'ember-views/system/jquery';
99
import TextField from 'ember-views/views/text_field';
10-
import Namespace from 'ember-runtime/system/namespace';
1110
import EmberObject from 'ember-runtime/system/object';
1211
import ContainerView from 'ember-views/views/container_view';
1312
import SafeString from 'htmlbars-util/safe-string';
@@ -130,27 +129,6 @@ QUnit.test('By default, without a container, EmberView is used', function() {
130129
ok(jQuery('#qunit-fixture').html().toUpperCase().match(/<SPAN/), 'contains view with span');
131130
});
132131

133-
QUnit.test('View lookup - App.FuView (DEPRECATED)', function() {
134-
Ember.lookup = {
135-
App: {
136-
FuView: viewClass({
137-
elementId: 'fu',
138-
template: compile('bro')
139-
})
140-
}
141-
};
142-
143-
view = viewClass({
144-
template: compile('{{view App.FuView}}')
145-
}).create();
146-
147-
expectDeprecation(function() {
148-
runAppend(view);
149-
}, /Global lookup of App from a Handlebars template is deprecated./);
150-
151-
equal(jQuery('#fu').text(), 'bro');
152-
});
153-
154132
QUnit.test('View lookup - \'fu\'', function() {
155133
var FuView = viewClass({
156134
elementId: 'fu',
@@ -848,46 +826,6 @@ QUnit.test('{{view}} should be able to point to a local view', function() {
848826
equal(view.$().text(), 'common', 'tries to look up view name locally');
849827
});
850828

851-
QUnit.test('{{view}} should evaluate class bindings set to global paths DEPRECATED', function() {
852-
var App;
853-
854-
run(function() {
855-
lookup.App = App = Namespace.create({
856-
isApp: true,
857-
isGreat: true,
858-
directClass: 'app-direct',
859-
isEnabled: true
860-
});
861-
});
862-
863-
view = EmberView.create({
864-
textField: TextField,
865-
template: compile('{{view view.textField class="unbound" classBinding="App.isGreat:great App.directClass App.isApp App.isEnabled:enabled:disabled"}}')
866-
});
867-
868-
expectDeprecation(function() {
869-
runAppend(view);
870-
});
871-
872-
ok(view.$('input').hasClass('unbound'), 'sets unbound classes directly');
873-
ok(view.$('input').hasClass('great'), 'evaluates classes bound to global paths');
874-
ok(view.$('input').hasClass('app-direct'), 'evaluates classes bound directly to global paths');
875-
ok(view.$('input').hasClass('is-app'), 'evaluates classes bound directly to booleans in global paths - dasherizes and sets class when true');
876-
ok(view.$('input').hasClass('enabled'), 'evaluates ternary operator in classBindings');
877-
ok(!view.$('input').hasClass('disabled'), 'evaluates ternary operator in classBindings');
878-
879-
run(function() {
880-
App.set('isApp', false);
881-
App.set('isEnabled', false);
882-
});
883-
884-
ok(!view.$('input').hasClass('is-app'), 'evaluates classes bound directly to booleans in global paths - removes class when false');
885-
ok(!view.$('input').hasClass('enabled'), 'evaluates ternary operator in classBindings');
886-
ok(view.$('input').hasClass('disabled'), 'evaluates ternary operator in classBindings');
887-
888-
runDestroy(lookup.App);
889-
});
890-
891829
QUnit.test('{{view}} should evaluate class bindings set in the current context', function() {
892830
view = EmberView.create({
893831
isView: true,
@@ -917,71 +855,6 @@ QUnit.test('{{view}} should evaluate class bindings set in the current context',
917855
ok(view.$('input').hasClass('disabled'), 'evaluates ternary operator in classBindings');
918856
});
919857

920-
QUnit.test('{{view}} should evaluate class bindings set with either classBinding or classNameBindings from globals DEPRECATED', function() {
921-
var App;
922-
923-
run(function() {
924-
lookup.App = App = Namespace.create({
925-
isGreat: true,
926-
isEnabled: true
927-
});
928-
});
929-
930-
view = EmberView.create({
931-
textField: TextField,
932-
template: compile('{{view view.textField class="unbound" classBinding="App.isGreat:great App.isEnabled:enabled:disabled" classNameBindings="App.isGreat:really-great App.isEnabled:really-enabled:really-disabled"}}')
933-
});
934-
935-
expectDeprecation(function() {
936-
runAppend(view);
937-
});
938-
939-
ok(view.$('input').hasClass('unbound'), 'sets unbound classes directly');
940-
ok(view.$('input').hasClass('great'), 'evaluates classBinding');
941-
ok(view.$('input').hasClass('really-great'), 'evaluates classNameBinding');
942-
ok(view.$('input').hasClass('enabled'), 'evaluates ternary operator in classBindings');
943-
ok(view.$('input').hasClass('really-enabled'), 'evaluates ternary operator in classBindings');
944-
ok(!view.$('input').hasClass('disabled'), 'evaluates ternary operator in classBindings');
945-
ok(!view.$('input').hasClass('really-disabled'), 'evaluates ternary operator in classBindings');
946-
947-
run(function() {
948-
App.set('isEnabled', false);
949-
});
950-
951-
ok(!view.$('input').hasClass('enabled'), 'evaluates ternary operator in classBindings');
952-
ok(!view.$('input').hasClass('really-enabled'), 'evaluates ternary operator in classBindings');
953-
ok(view.$('input').hasClass('disabled'), 'evaluates ternary operator in classBindings');
954-
ok(view.$('input').hasClass('really-disabled'), 'evaluates ternary operator in classBindings');
955-
956-
runDestroy(lookup.App);
957-
});
958-
959-
QUnit.test('{{view}} should evaluate other attribute bindings set to global paths [DEPRECATED]', function() {
960-
run(function() {
961-
lookup.App = Namespace.create({
962-
name: 'myApp'
963-
});
964-
});
965-
966-
var template;
967-
expectDeprecation(function() {
968-
template = compile('{{view view.textField valueBinding="App.name"}}');
969-
}, /You're using legacy binding syntax: valueBinding/);
970-
971-
view = EmberView.create({
972-
textField: TextField,
973-
template
974-
});
975-
976-
expectDeprecation(function() {
977-
runAppend(view);
978-
}, 'Global lookup of App from a Handlebars template is deprecated.');
979-
980-
equal(view.$('input').val(), 'myApp', 'evaluates attributes bound to global paths');
981-
982-
runDestroy(lookup.App);
983-
});
984-
985858
QUnit.test('{{view}} should evaluate other attributes bindings set in the current context', function() {
986859
view = EmberView.create({
987860
name: 'myView',

‎packages/ember-htmlbars/tests/helpers/with_test.js

-30
Original file line numberDiff line numberDiff line change
@@ -129,36 +129,6 @@ QUnit.test('nested {{with}} blocks shadow the outer scoped variable properly.',
129129
equal(view.$().text(), 'Limbo-Wrath-Treachery-Wrath-Limbo', 'should be properly scoped after updating');
130130
});
131131

132-
QUnit.module('Handlebars {{#with}} globals helper [DEPRECATED]', {
133-
setup() {
134-
Ember.lookup = lookup = { Ember: Ember };
135-
136-
lookup.Foo = { bar: 'baz' };
137-
view = EmberView.create({
138-
template: compile('{{#with Foo.bar as |qux|}}{{qux}}{{/with}}')
139-
});
140-
},
141-
142-
teardown() {
143-
runDestroy(view);
144-
Ember.lookup = originalLookup;
145-
}
146-
});
147-
148-
QUnit.test('it should support #with Foo.bar as |qux| [DEPRECATED]', function() {
149-
expectDeprecation(function() {
150-
runAppend(view);
151-
}, /Global lookup of Foo from a Handlebars template is deprecated/);
152-
153-
equal(view.$().text(), 'baz', 'should be properly scoped');
154-
155-
run(function() {
156-
set(lookup.Foo, 'bar', 'updated');
157-
});
158-
159-
equal(view.$().text(), 'updated', 'should update');
160-
});
161-
162132
QUnit.module('Handlebars {{#with keyword as |foo|}}');
163133

164134
QUnit.test('it should support #with view as |foo|', function() {

‎packages/ember-htmlbars/tests/integration/escape_integration_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { runAppend, runDestroy } from 'ember-runtime/tests/utils';
77

88
var view;
99

10-
QUnit.module('ember-htmlbars: Integration with Globals', {
10+
QUnit.module('ember-htmlbars: Escaped Integration', {
1111
teardown() {
1212
runDestroy(view);
1313

0 commit comments

Comments
 (0)
Failed to load comments.