Skip to content

Commit

Permalink
Fix for #91 that works with minified KO.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagacity committed Jul 31, 2012
1 parent 28adba3 commit 6158b02
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion knockout.mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@
// We wrap the original dependent observable so that we can remove it from the 'dependentObservables' list we need to evaluate after mapping has
// completed if the user already evaluated the DO themselves in the meantime.
var wrap = function (DO) {
// Temporarily revert ko.dependentObservable, since it is used in ko.isWriteableObservable
var tmp = ko.dependentObservable;
ko.dependentObservable = realKoDependentObservable;
var isWriteable = ko.isWriteableObservable(DO);
ko.dependentObservable = tmp;

var wrapped = realKoDependentObservable({
read: function () {
if (!isRemoved) {
Expand All @@ -236,7 +242,7 @@
}
return DO.apply(DO, arguments);
},
write: DO.hasWriteFunction && function (val) {
write: isWriteable && function (val) {
return DO(val);
},
deferEvaluation: true
Expand Down

0 comments on commit 6158b02

Please sign in to comment.