SteveSanderson/knockout — Issue #275: Anonymous templates are being regenerated when their bound value has not changed
Author: cdmicacc
Created: 2012-01-13 00:19:18+00:00
State: open

If you have an anonymous template (e.g. with the "with" binding) coupled with a dependentObservable (e.g. with the "visible" binding), changes to the values of the dependencies of the dependentObservable cause the template to rerender, **even though the value that changed was not related to the template binding**.

See this fiddle for a simple example: http://jsfiddle.net/cdmicacc/yDgZS/

I have a fairly complex page with large divs bound to visible bindings. Inside I have several elements that use my own custom bindings, and I was seeing that changing one of the conditions on which the visible binding depended resulted in all my custom binding's "init" handlers being called again. This results in a very marked slowdown on the page as the entire (complex) template is recreated, including calling some expensive init handlers.

I'm not sure why a change to the value of the "visible" observable is causing a re-evaluation of the "with" observable, but it seems like a bug to me.