SteveSanderson/knockout — Issue #170: Observable _destroy property causing template not to render.
Author: bmac
Created: 2011-10-08 19:00:53+00:00
State: open

When using a knockout's template binding with the foreach syntax on an object that has an observable _destroy property, knockout mistakenly evaluates the observable as true and fails to render the template for the object. The _destroy property can become an onservable when loaded with the knockout mapping plugin's ko.mapping.fromJS. Setting the adding the string copy options to '_destroy' should only not wrap the property in an observable but it does not work for nested properties.

Demo of the issue http://jsfiddle.net/TC8Cu/2/

To fix this the test for if _destroy is true in src/templating/templating.js should be wraped in a call to ko.utils.unwrapObservable().

If knockout starts supporting an observable _destroy property the destroy function in src/subscribables/observableArray.js should be updated to check if _destroy is an observable before setting the property to true.