knockout issue #2480 (template binding)

by fastfasterfastest

HTML

<script src="https://unpkg.com/[email protected]/build/output/knockout-latest.debug.js"></script>
<div data-bind="template: { name: 'item-template', data: createItem() }"></div>

<script type="text/html" id="item-template">
    <span data-bind="text: name"></span>
</script>

JavaScript

let _totalItems = 0;

/** @constructor */
function Item() {
  this.name = `item ${++_totalItems}`;
}

ko.applyBindings({
  createItem() {
    return new Item();
  }
});