diff --git a/src/subscribables/dependentObservable.js b/src/subscribables/dependentObservable.js index 98e48f570..3ed5dcdc6 100644 --- a/src/subscribables/dependentObservable.js +++ b/src/subscribables/dependentObservable.js @@ -59,8 +59,13 @@ ko.dependentObservable = function (evaluatorFunctionOrOptions, evaluatorFunction } function evaluateImmediate() { - if (_isBeingEvaluated) + if (_isBeingEvaluated) { + // If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation. + // This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost + // certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing + // their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387 return; + } // Don't dispose on first evaluation, because the "disposeWhen" callback might // e.g., dispose when the associated DOM element isn't in the doc, and it's not