knockout/knockout — pull request #1206 by mbest (2014-02-04 09:13:48+00:00)
Title: For observable view models, $rawData should be the observable

When using the following `withlight` binding that supports binding a child observable view model, `$rawData` will be the function passed to `createChildContext` instead of the observable view model itself:

```
ko.bindingHandlers.withlight = {
'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {
var innerContext = bindingContext.createChildContext(function() {
return ko.unwrap(valueAccessor());
});
ko.applyBindingsToDescendants(innerContext, element);
return { controlsDescendantBindings: true };
}
};
```

The following version will have the correct `$rawData` since it doesn't use an intermediate function, but it will not update correctly if the view model is specified dynamically in the binding (like `withlight: x() ? vm1 : vm2`):

```
ko.bindingHandlers.withlight = {
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
var innerContext = bindingContext.createChildContext(valueAccessor());
ko.applyBindingsToDescendants(innerContext, element);
return { controlsDescendantBindings: true };
}
};
```