diff --git a/src/TemplateBinding.js b/src/TemplateBinding.js index 9467b62..c66e1a5 100644 --- a/src/TemplateBinding.js +++ b/src/TemplateBinding.js @@ -653,10 +653,9 @@ function processSinglePathBinding(name, tokens, node, model) { var delegateFn = tokens[2]; var delegateValue = delegateFn && delegateFn(model, node); - if (Observer.isObservable(delegateValue)) - return delegateValue; + var observer = Observer.isObservable(delegateValue) ? delegateValue : + new PathObserver(model, tokens[1]); - var observer = new PathObserver(model, tokens[1]); return tokens.isSimplePath ? observer : new ObserverTransform(observer, tokens.combinator); } diff --git a/tests/tests.js b/tests/tests.js index ad0e5b0..9501d0a 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -2166,6 +2166,34 @@ suite('Binding Delegate API', function() { assert.equal('barValue', div.lastChild.getAttribute('bar')); }); + + test('issue-18', function() { + + var delegate = { + prepareBinding: function(path, name, node) { + if (name != 'class') + return; + + return function(model) { + return new PathObserver(model, path); + } + } + }; + + var div = createTestHtml( + ''); + + var model = { + bar: 2 + }; + + recursivelySetTemplateModel(div, model, delegate); + Platform.performMicrotaskCheckpoint(); + + assert.equal('foo: 2', div.lastChild.getAttribute('class')); + }); }); suite('Compat', function() {