Skip to content

Commit

Permalink
3.5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
cherifGsoul committed May 24, 2019
1 parent 7ddbaa1 commit 690b332
Show file tree
Hide file tree
Showing 2 changed files with 2,186 additions and 0 deletions.
178 changes: 178 additions & 0 deletions dist/amd/can-construct.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
/*can-construct@3.5.5#can-construct*/
define([
'require',
'exports',
'module',
'can-reflect',
'can-log/dev',
'can-namespace',
'can-symbol'
], function (require, exports, module) {
'use strict';
var canReflect = require('can-reflect');
var dev = require('can-log/dev');
var namespace = require('can-namespace');
var canSymbol = require('can-symbol');
var inSetupSymbol = canSymbol.for('can.initializing');
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]);
}
}, defineNonEnumerable = function (obj, prop, value) {
Object.defineProperty(obj, prop, {
configurable: true,
writable: true,
enumerable: false,
value: value
});
};
canReflect.assignMap(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
});
Object.defineProperty(inst, inSetupSymbol, {
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;
inst[inSetupSymbol] = 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) {
var defaults = base.defaults ? canReflect.serialize(base.defaults) : {};
this.defaults = canReflect.assignDeepMap(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);
canReflect.assignMap(Constructor, {
constructor: Constructor,
prototype: prototype
});
if (shortName !== undefined) {
if (Object.getOwnPropertyDescriptor) {
var desc = Object.getOwnPropertyDescriptor(Constructor, 'name');
if (!desc || desc.configurable) {
Object.defineProperty(Constructor, 'name', {
writable: true,
value: shortName,
configurable: true
});
}
}
Constructor.shortName = shortName;
}
defineNonEnumerable(Constructor.prototype, 'constructor', Constructor);
var t = [_super_class].concat(Array.prototype.slice.call(arguments)), args = Constructor.setup.apply(Constructor, t);
if (Constructor.init) {
Constructor.init.apply(Constructor, args || t);
}
return Constructor;
},
ReturnValue: function (value) {
this.value = value;
}
});
defineNonEnumerable(Construct.prototype, 'setup', function () {
});
defineNonEnumerable(Construct.prototype, 'init', function () {
});
module.exports = namespace.Construct = Construct;
});
Loading

0 comments on commit 690b332

Please sign in to comment.