I developed a tree view that uses knockout to display a hierarchy. I noticed a strange situation inside chrome that occurs when I destroy a node in a tree. The text for the node disappears along with the elements below it. I realized that I had something wrong with my code, and then found out that it works correctly in both IE and firefox. I created the fiddle below which demonstrates the problem with any additional code from my page. If you expand the node and then collapse it (the plus button does not change to minus, as in my full code), the text will disappear. Then you can simply click anywhere on the page to bring the text back.
Text that disappears has been highlighted in red, as recommended in the comment, and can be seen in the screenshot.

I tested this on 4 machines, and on each of them it does not work when I use Chrome. Is this a bug in Chrome, or am I doing something wrong? Also, can anyone see any way around this issue if this is a bug in Chrome?
Script example
console.clear(); var hierarchyNode = function (parent) { var self = this; this.name = "Node Name"; this.hasChildren = ko.observable(true); this.childNodes = ko.observableArray(); this.expanded = ko.observable(false); }; hierarchyNode.prototype = { name: null, hasChildren: null, childNodes: null, getChildNodes: function (element, event) { if (element.hasChildren() === true && element.childNodes().length === 0) { element.childNodes.push(new hierarchyNode(element)); } element.expanded(!element.expanded()); } }; var hierarchyVM = function () { var self = this; self.hierarchyNodes = ko.observableArray(); self.selectItem = function () {}; }; var vm = new hierarchyVM(); vm.hierarchyNodes.push(new hierarchyNode(null)); console.log(vm.hierarchyNodes()[0]); ko.applyBindings(vm);
ul.tree { list-style-type: none; padding-left: 10px; } .hierarchyNode {border: 1px solid red;}
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ul class="tree" data-bind="template: { name: 'itemTmpl', foreach: $data.hierarchyNodes }"></ul> <script id="itemTmpl" type="text/html"> <li> <button data-bind="click: getChildNodes">+</button> <div data-bind="visible: hasChildren() == false" class="tree-spacer"></div> <span data-bind="text: name" class="no_selection hierarchyNode"></span> <ul class="tree" data-bind="template: { name: 'itemTmpl', foreach: $data.childNodes }, visible: expanded"></ul> </li> </script>
source share