knockout fix
by CodeRenaissance
JavaScript
ko.dependencyDetection = (function () {
var _frames = [];
return {
begin: function fnBeginDependencyDetection(callback) {
_frames.push({ callback: callback, distinctDependencies: {} });
},
end: function fnEndDependencyDetection() {
_frames.pop();
},
registerDependency: function fnRegisterDependency(subscribable) {
if (!ko.isSubscribable(subscribable))
throw new Error("Only subscribable things can act as dependencies");
if (_frames.length > 0) {
var topFrame = _frames[_frames.length - 1];
subscribable.key = subscribable.key || ko.memoization.generateRandomId();
if (!topFrame || topFrame.distinctDependencies[subscribable.key])//ko.utils.arrayIndexOf(topFrame.distinctDependencies, subscribable) >= 0)
return;
topFrame.distinctDependencies[subscribable.key] = true;
//topFrame.distinctDependencies.push(subscribable);
topFrame.callback(subscribable);
}
},
ignore: function fnIgnoreDependency(callback, callbackTarget, callbackArgs) {
try {
_frames.push(null);
return callback.apply(callbackTarget, callbackArgs || []);
} finally {
_frames.pop();
}
}
};
})();