Permalink
Browse files

Merge branch 'master' of github.com:documentcloud/backbone

  • Loading branch information...
2 parents 289d4e0 + 440d141 commit 39cabb8ac85de49cb7a3c4c9925e8cca11693f79 @jashkenas jashkenas committed Jan 11, 2011
Showing with 27 additions and 0 deletions.
  1. +3 −0 backbone.js
  2. +24 −0 test/model.js
View
@@ -1004,6 +1004,9 @@
child = function(){ return parent.apply(this, arguments); };
}
+ // Inherit class (static) properties from parent.
+ _.extend(child, parent);
+
// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
ctor.prototype = parent.prototype;
View
@@ -322,5 +322,29 @@ $(document).ready(function() {
equals(lastError, "Can't change admin status.");
equals(boundError, undefined);
});
+
+ test("Model: Inherit class properties", function() {
+ var Parent = Backbone.Model.extend({
+ instancePropSame: function() {},
+ instancePropDiff: function() {}
+ }, {
+ classProp: function() {}
+ });
+ var Child = Parent.extend({
+ instancePropDiff: function() {}
+ });
+
+ var adult = new Parent;
+ var kid = new Child;
+
+ equals(Child.classProp, Parent.classProp);
+ notEqual(Child.classProp, undefined);
+
+ equals(kid.instancePropSame, adult.instancePropSame);
+ notEqual(kid.instancePropSame, undefined);
+
+ notEqual(Child.prototype.instancePropDiff, Parent.prototype.instancePropDiff);
+ notEqual(Child.prototype.instancePropDiff, undefined);
+ });
});

0 comments on commit 39cabb8

Please sign in to comment.