MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / extend

Function extend

public/javascripts/backbone.js:1521–1552  ·  view source on GitHub ↗
(protoProps, staticProps)

Source from the content-addressed store, hash-verified

1519 // Similar to `goog.inherits`, but uses a hash of prototype properties and
1520 // class properties to be extended.
1521 var extend = function(protoProps, staticProps) {
1522 var parent = this;
1523 var child;
1524
1525 // The constructor function for the new subclass is either defined by you
1526 // (the "constructor" property in your `extend` definition), or defaulted
1527 // by us to simply call the parent's constructor.
1528 if (protoProps && _.has(protoProps, 'constructor')) {
1529 child = protoProps.constructor;
1530 } else {
1531 child = function(){ return parent.apply(this, arguments); };
1532 }
1533
1534 // Add static properties to the constructor function, if supplied.
1535 _.extend(child, parent, staticProps);
1536
1537 // Set the prototype chain to inherit from `parent`, without calling
1538 // `parent`'s constructor function.
1539 var Surrogate = function(){ this.constructor = child; };
1540 Surrogate.prototype = parent.prototype;
1541 child.prototype = new Surrogate;
1542
1543 // Add prototype properties (instance properties) to the subclass,
1544 // if supplied.
1545 if (protoProps) _.extend(child.prototype, protoProps);
1546
1547 // Set a convenience property in case the parent's prototype is needed
1548 // later.
1549 child.__super__ = parent.prototype;
1550
1551 return child;
1552 };
1553
1554 // Set up inheritance for the model, collection, router, view and history.
1555 Model.extend = Collection.extend = Router.extend = View.extend = History.extend = extend;

Callers 2

DropzoneFunction · 0.70
dropzone.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected