Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't override extensions to ko.dependentObservable while mapping, Fixes #71 #72

Merged
merged 1 commit into from

2 participants

James Foster Roy Jacobs
James Foster

No description provided.

Roy Jacobs RoyJacobs merged commit 01e6cbd into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 2 deletions.
  1. +1 −2  knockout.mapping.js
  2. +26 −0 spec/proxyDependentObservableBehaviors.js
3  knockout.mapping.js
View
@@ -231,13 +231,11 @@
},
deferEvaluation: true
});
- wrapped.__ko_proto__ = realKoDependentObservable;
return wrapped;
};
options.deferEvaluation = true; // will either set for just options, or both read/options.
var realDependentObservable = new realKoDependentObservable(read, owner, options);
- realDependentObservable.__ko_proto__ = realKoDependentObservable;
if (!realDeferEvaluation) {
realDependentObservable = wrap(realDependentObservable);
@@ -246,6 +244,7 @@
return realDependentObservable;
}
+ ko.dependentObservable.fn = realKoDependentObservable.fn;
ko.computed = ko.dependentObservable;
var result = callback();
ko.dependentObservable = localDO;
26 spec/proxyDependentObservableBehaviors.js
View
@@ -339,6 +339,32 @@ var generateProxyTests = function(useComputed) {
equal(i.evaluationCount, 2);
});
});
+
+ test('dependentObservable.fn extensions are not missing during mapping', function() {
+ var obj = {
+ x: 1
+ };
+
+ var model = function(data) {
+ var _this = this;
+
+ ko.mapping.fromJS(data, {}, _this);
+
+ _this.DO = func(_this.x);
+ };
+
+ var mapping = {
+ create: function(options) {
+ return new model(options.data);
+ }
+ };
+
+ ko.dependentObservable.fn.myExtension = true;
+
+ var mapped = ko.mapping.fromJS(obj, mapping);
+
+ equal(mapped.DO.myExtension, true)
+ });
};
generateProxyTests(false);
Something went wrong with that request. Please try again.