mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-08 03:00:26 -04:00
Make protoProps optional, when inheriting.
This commit is contained in:
@@ -751,7 +751,7 @@
|
||||
// The constructor function for the new subclass is either defined by you
|
||||
// (the "constructor" property in your `extend` definition), or defaulted
|
||||
// by us to simply call `super()`.
|
||||
if (protoProps.hasOwnProperty('constructor')) {
|
||||
if (protoProps && protoProps.hasOwnProperty('constructor')) {
|
||||
child = protoProps.constructor;
|
||||
} else {
|
||||
child = function(){ return parent.apply(this, arguments); };
|
||||
@@ -762,8 +762,9 @@
|
||||
ctor.prototype = parent.prototype;
|
||||
child.prototype = new ctor();
|
||||
|
||||
// Add prototype properties (instance properties) to the subclass.
|
||||
_.extend(child.prototype, protoProps);
|
||||
// Add prototype properties (instance properties) to the subclass,
|
||||
// if supplied.
|
||||
if (protoProps) _.extend(child.prototype, protoProps);
|
||||
|
||||
// Add static properties to the constructor function, if supplied.
|
||||
if (staticProps) _.extend(child, staticProps);
|
||||
|
||||
@@ -19,7 +19,8 @@ $(document).ready(function() {
|
||||
length : 123
|
||||
};
|
||||
|
||||
var doc = new Backbone.Model(attrs);
|
||||
var proxy = Backbone.Model.extend();
|
||||
var doc = new proxy(attrs);
|
||||
|
||||
var klass = Backbone.Collection.extend({
|
||||
url : function() { return '/collection'; }
|
||||
|
||||
Reference in New Issue
Block a user