SteveSanderson/knockout — pull request #587 by barclayadam (2012-07-29 17:13:25+00:00)
Title: Enable preprocessing nodes during binding

I have found the need to, from a binding provider, preprocess the nodes that are being bound in a way that cannot currently be done (AFAICT).

To support something akin to the functionality of allowing custom HTML tags as [AngularJS](http://angularjs.org/) does, from a custom binding provider I am using the name of the tag to determine what binding provider to use. This all works fine in most browsers, except in IE < 9, where setting text content and child nodes will not work, requiring the [HTML5 Shiv](https://github.com/aFarkas/html5shiv) to enable this functionality (i.e. I need to create a new element and replace the existing one).

To support this functionality I have made a small addition to the `applyBindingsToNodeInternal` that allows the current `bindingProvider` to preprocess, and potentially replace, the current node:

```javascript
var preprocessNode = ko.bindingProvider['instance']['preprocessNode'];

if (preprocessNode) {
node = preprocessNode(node) || node;
}
```

As it currently stands I have not done extensive testing of how this may affect other parts of knockout, but at the least all current tests pass. I've added a couple of simple tests, but they could probably be expanded on with more scenarios.