Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed problem with dependentKeys on registerBoundHelper.

  • Loading branch information...
commit 0226e1c605f84e469e56c7c397599a4295946094 1 parent 3394b82
@arturmalecki authored
View
7 packages/ember-handlebars/lib/ext.js
@@ -260,7 +260,7 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
view = data.view,
currentContext = (options.contexts && options.contexts[0]) || this,
normalized,
- pathRoot, path,
+ pathRoot, path, prefixPathForDependentKeys = '',
loc, hashOption;
Ember.assert("registerBoundHelper-generated helpers do not support use with Handlebars blocks.", !options.fn);
@@ -311,8 +311,11 @@ Ember.Handlebars.registerBoundHelper = function(name, fn) {
view.registerObserver(pathRoot, path, bindView, bindView.rerender);
+ if(!Ember.isEmpty(path)) {
+ prefixPathForDependentKeys = path + '.';
+ }
for (var i=0, l=dependentKeys.length; i<l; i++) {
- view.registerObserver(pathRoot, path + '.' + dependentKeys[i], bindView, bindView.rerender);
+ view.registerObserver(pathRoot, prefixPathForDependentKeys + dependentKeys[i], bindView, bindView.rerender);
}
}
View
25 packages/ember-handlebars/tests/helpers/bound_helper_test.js
@@ -253,3 +253,28 @@ test("bound helpers should not be invoked with blocks", function() {
}, /registerBoundHelper-generated helpers do not support use with Handlebars blocks/i);
});
+test("should observe dependent keys passed to registerBoundHelper", function() {
+ expect(2);
+
+ var SimplyObject = Ember.Object.create({
+ firstName: 'Jim',
+ lastName: 'Owen'
+ });
+
+ Ember.Handlebars.registerBoundHelper('fullName', function(value){
+ return value.get('firstName') + ' ' + value.get('lastName');
+ }, 'firstName', 'lastName');
+
+ view = Ember.View.create({
+ template: Ember.Handlebars.compile('{{fullName this}}'),
+ context: SimplyObject
+ });
+ appendView(view);
+
+ equal(view.$().text(), 'Jim Owen', 'simply render the helper');
+
+ Ember.run(SimplyObject, SimplyObject.set, 'firstName', 'Tom');
+
+ equal(view.$().text(), 'Tom Owen', 'simply render the helper');
+});
+
Please sign in to comment.
Something went wrong with that request. Please try again.