More work on Bootstrap core.

This commit is contained in:
Jürg Lehni 2011-03-04 21:46:50 +00:00
parent 9bd8950e33
commit 8a61599c7d

39
lib/bootstrap.js vendored
View file

@ -16,18 +16,11 @@
* where deemeded necessary.
* See http://www.bootstrap-js.net/wiki/MootoolsDifferences
*/
var Base = new function() {
var fix = !this.__proto__ && [Function, Number, Boolean, String, Array, Date, RegExp];
if (fix)
for (var i in fix)
fix[i].prototype.__proto__ = fix[i].prototype;
function has(obj, name) {
return (!fix || name != '__proto__') && obj.hasOwnProperty(name);
}
var _define = Object.defineProperty,
_describe = Object.getOwnPropertyDescriptor,
var Base = new function() {
var fix = !this.__proto__,
has = fix ? function(name) {
return name != '__proto__' && this.hasOwnProperty(name);
} : {}.hasOwnProperty,
slice = Array.prototype.slice,
forEach = Array.prototype.forEach || function(iter, bind) {
for (var i = 0, l = this.length; i < l; i++)
@ -35,7 +28,9 @@ var Base = new function() {
},
isArray = Array.isArray || function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
};
},
_define = Object.defineProperty,
_describe = Object.getOwnPropertyDescriptor;
function define(obj, name, desc) {
if (_define)
@ -55,7 +50,7 @@ var Base = new function() {
var get = obj.__lookupGetter__ && obj.__lookupGetter__(name);
return get
? { enumerable: true, configurable: true, get: get, set: obj.__lookupSetter__(name) }
: has(obj, name)
: has.call(obj, name)
? { enumerable: true, configurable: true, writable: true, value: obj[name] }
: null;
}
@ -70,7 +65,7 @@ var Base = new function() {
if (generics && func && (!preserve || !generics[name])) generics[name] = function(bind) {
return bind && dest[name].apply(bind, slice.call(arguments, 1));
}
if ((dontCheck || val !== undefined && has(src, name)) && (!preserve || !prev)) {
if ((dontCheck || val !== undefined && has.call(src, name)) && (!preserve || !prev)) {
if (func) {
if (prev && /\bthis\.base\b/.test(val)) {
var fromBase = base && base[name] == prev;
@ -96,7 +91,7 @@ var Base = new function() {
if (src) {
beans = src.beans && [];
for (var name in src)
if (has(src, name) && !/^(statics|generics|preserve|beans|prototype|__proto__|toString|valueOf)$/.test(name))
if (has.call(src, name) && !/^(statics|generics|preserve|beans|prototype|__proto__|toString|valueOf)$/.test(name))
field(name, null, true, generics);
field('toString');
field('valueOf');
@ -186,10 +181,7 @@ var Base = new function() {
}
return Object.extend({
has: function(name) {
return has(this, name);
},
has: has,
each: each,
inject: function() {
@ -208,15 +200,20 @@ var Base = new function() {
},
statics: {
has: has,
// TODO: Use generics?
has: function(obj, name) {
return has.call(obj, name);
},
each: function(obj, iter, bind) {
return each.call(obj, iter, bind);
},
clone: clone,
define: define,
describe: describe,
iterator: iterator,
isArray: isArray,
type: function(obj) {
return (obj || obj === 0) && (obj._type || typeof obj) || null;