-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.js
30 lines (28 loc) · 988 Bytes
/
object.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// From Backbone
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Backbone may be freely distributed under the MIT license.
var ctor = function(){};
function objInherits (parent, protoProps, staticProps) {
var child;
if (protoProps && protoProps.hasOwnProperty('constructor')) {
child = protoProps.constructor;
} else {
child = function(){ parent.apply(this, arguments); };
}
extend(child, parent);
ctor.prototype = parent.prototype;
child.prototype = new ctor();
if (protoProps) extend(child.prototype, protoProps);
if (staticProps) extend(child, staticProps);
child.prototype.constructor = child;
child.__super__ = parent.prototype;
return child;
}
// The self-propagating extend function that Backbone classes use.
function objExtend (protoProps, classProps) {
var child = objInherits(this, protoProps, classProps);
child.extend = objExtend;
return child;
}
function Obj () {}
Obj.extend = objExtend;