Skip to content

Commit

Permalink
3.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
imaustink committed Oct 31, 2017
1 parent 0c6ff92 commit cd385cb
Show file tree
Hide file tree
Showing 3 changed files with 7,607 additions and 0 deletions.
154 changes: 154 additions & 0 deletions dist/amd/can-construct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*can-construct@3.2.2#can-construct*/
define([
'require',
'exports',
'module',
'can-util/js/assign',
'can-util/js/deep-assign',
'can-util/js/dev',
'can-util/js/make-array',
'can-namespace'
], function (require, exports, module) {
'use strict';
var assign = require('can-util/js/assign');
var deepAssign = require('can-util/js/deep-assign');
var dev = require('can-util/js/dev');
var makeArray = require('can-util/js/make-array');
var namespace = require('can-namespace');
var initializing = 0;
var Construct = function () {
if (arguments.length) {
return Construct.extend.apply(Construct, arguments);
}
};
var canGetDescriptor;
try {
Object.getOwnPropertyDescriptor({});
canGetDescriptor = true;
} catch (e) {
canGetDescriptor = false;
}
var getDescriptor = function (newProps, name) {
var descriptor = Object.getOwnPropertyDescriptor(newProps, name);
if (descriptor && (descriptor.get || descriptor.set)) {
return descriptor;
}
return null;
}, inheritGetterSetter = function (newProps, oldProps, addTo) {
addTo = addTo || newProps;
var descriptor;
for (var name in newProps) {
if (descriptor = getDescriptor(newProps, name)) {
this._defineProperty(addTo, oldProps, name, descriptor);
} else {
Construct._overwrite(addTo, oldProps, name, newProps[name]);
}
}
}, simpleInherit = function (newProps, oldProps, addTo) {
addTo = addTo || newProps;
for (var name in newProps) {
Construct._overwrite(addTo, oldProps, name, newProps[name]);
}
};
assign(Construct, {
constructorExtends: true,
newInstance: function () {
var inst = this.instance(), args;
if (inst.setup) {
Object.defineProperty(inst, '__inSetup', {
configurable: true,
enumerable: false,
value: true,
writable: true
});
args = inst.setup.apply(inst, arguments);
if (args instanceof Construct.ReturnValue) {
return args.value;
}
inst.__inSetup = false;
}
if (inst.init) {
inst.init.apply(inst, args || arguments);
}
return inst;
},
_inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit,
_defineProperty: function (what, oldProps, propName, descriptor) {
Object.defineProperty(what, propName, descriptor);
},
_overwrite: function (what, oldProps, propName, val) {
Object.defineProperty(what, propName, {
value: val,
configurable: true,
enumerable: true,
writable: true
});
},
setup: function (base) {
this.defaults = deepAssign(true, {}, base.defaults, this.defaults);
},
instance: function () {
initializing = 1;
var inst = new this();
initializing = 0;
return inst;
},
extend: function (name, staticProperties, instanceProperties) {
var shortName = name, klass = staticProperties, proto = instanceProperties;
if (typeof shortName !== 'string') {
proto = klass;
klass = shortName;
shortName = null;
}
if (!proto) {
proto = klass;
klass = null;
}
proto = proto || {};
var _super_class = this, _super = this.prototype, Constructor, prototype;
prototype = this.instance();
Construct._inherit(proto, _super, prototype);
if (shortName) {
} else if (klass && klass.shortName) {
shortName = klass.shortName;
} else if (this.shortName) {
shortName = this.shortName;
}
function init() {
if (!initializing) {
return (!this || this.constructor !== Constructor) && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments);
}
}
Constructor = typeof namedCtor === 'function' ? namedCtor(constructorName, init) : function () {
return init.apply(this, arguments);
};
for (var propName in _super_class) {
if (_super_class.hasOwnProperty(propName)) {
Constructor[propName] = _super_class[propName];
}
}
Construct._inherit(klass, _super_class, Constructor);
assign(Constructor, {
constructor: Constructor,
prototype: prototype
});
if (shortName !== undefined) {
Constructor.shortName = shortName;
}
Constructor.prototype.constructor = Constructor;
var t = [_super_class].concat(makeArray(arguments)), args = Constructor.setup.apply(Constructor, t);
if (Constructor.init) {
Constructor.init.apply(Constructor, args || t);
}
return Constructor;
},
ReturnValue: function (value) {
this.value = value;
}
});
Construct.prototype.setup = function () {
};
Construct.prototype.init = function () {
};
module.exports = namespace.Construct = Construct;
});
Loading

0 comments on commit cd385cb

Please sign in to comment.