mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 11:17:04 +00:00
[Framework] Allow prototype-style constructors
WTD-1482.
This commit is contained in:
parent
a77920bd18
commit
3a0ba4f5a6
@ -46,7 +46,6 @@ define(
|
||||
var key = extension.key,
|
||||
dependencies = extension.depends || [];
|
||||
|
||||
|
||||
if (!key) {
|
||||
$log.warn([
|
||||
"Cannot register ",
|
||||
|
@ -44,13 +44,20 @@ define(
|
||||
implPromise = loader.load(implPath),
|
||||
definition = extension.getDefinition();
|
||||
|
||||
// Wrap a constructor function (to avoid modifying the original)
|
||||
function constructorFor(impl) {
|
||||
function Constructor() {
|
||||
return impl.apply(this, arguments);
|
||||
}
|
||||
Constructor.prototype = impl.prototype;
|
||||
return Constructor;
|
||||
}
|
||||
|
||||
// Attach values from the object definition to the
|
||||
// loaded implementation.
|
||||
function attachDefinition(impl) {
|
||||
var result = (typeof impl === 'function') ?
|
||||
function () {
|
||||
return impl.apply({}, arguments);
|
||||
} :
|
||||
constructorFor(impl) :
|
||||
Object.create(impl);
|
||||
|
||||
// Copy over static properties
|
||||
|
Loading…
Reference in New Issue
Block a user