(function (root, factory) {
  if(typeof define === 'function' && define.amd) {
    define(['knockout'], factory);
  } else {
    factory(root.ko);
  }
}(this, function(ko) {
  ko.bindingHandlers.bindHtml = {
    update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
      ko.unwrap(valueAccessor());

      var children = element.children;
      for (var i = 0; i < children.length; i++) {
        ko.applyBindings(bindingContext.$data, children[i]);
      }
    }
  };
}));

(function (root, factory) {
  if(typeof define === 'function' && define.amd) {
    define(['knockout'], factory);
  } else {
    factory(root.ko);
  }
}(this, function(ko) {
  ko.bindingHandlers.bindHtml = {
    update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
      ko.unwrap(valueAccessor());
      ko.applyBindingsToDescendants(bindingContext.$data, element);
    }
  };

  ko.bindingHandlers.bindHtml.preprocess = function(value, name, addBinding) {
      addBinding('html', value);
      return value;
  };
}));

Refactor Use preprocess to handle html binding as well. Use descendants function to handle binding instead of looping through children.
Refactor
Use preprocess to handle html binding as well.
Use descendants function to handle binding instead of looping through
children.
