diff --git a/spec/bindingAttributeBehaviors.js b/spec/bindingAttributeBehaviors.js index 1605770da..b99035dbf 100644 --- a/spec/bindingAttributeBehaviors.js +++ b/spec/bindingAttributeBehaviors.js @@ -322,7 +322,7 @@ describe('Binding attribute syntax', { ko.applyBindings(null, testNode); value_of(ko.contextFor(testNode.childNodes[1].childNodes[0])).should_be(innerContext); value_of(ko.contextFor(testNode.childNodes[1].childNodes[1]).$parent).should_be(innerContext.$data); - value_of(ko.contextFor(testNode.childNodes[1].childNodes[1]).custom).should_be(true); + value_of(ko.contextFor(testNode.childNodes[1].childNodes[1]).$parentContext.custom).should_be(true); }, 'Should not reinvoke init for notifications triggered during first evaluation': function () { diff --git a/src/binding/bindingAttributeSyntax.js b/src/binding/bindingAttributeSyntax.js index e3454817e..eac7270ef 100755 --- a/src/binding/bindingAttributeSyntax.js +++ b/src/binding/bindingAttributeSyntax.js @@ -2,17 +2,17 @@ ko.bindingHandlers = {}; ko.bindingContext = function(dataItem, parentBindingContext) { + this['$data'] = dataItem; if (parentBindingContext) { - // copy all properties from parent binding context - ko.utils.extend(this, parentBindingContext); + this['$parentContext'] = parentBindingContext; this['$parent'] = parentBindingContext['$data']; - this['$parents'] = (this['$parents'] || []).slice(0); + this['$parents'] = (parentBindingContext['$parents'] || []).slice(0); this['$parents'].unshift(this['$parent']); + this['$root'] = parentBindingContext['$root']; } else { this['$parents'] = []; this['$root'] = dataItem; } - this['$data'] = dataItem; } ko.bindingContext.prototype['createChildContext'] = function (dataItem) { return new ko.bindingContext(dataItem, this);