Update straps.js to latest version.

This commit is contained in:
Jürg Lehni 2013-05-27 18:27:54 -07:00
parent 70d6050900
commit 099a5546cb

View file

@ -21,15 +21,14 @@
var Base = new function() {
var hidden = /^(statics|generics|preserve|enumerable|prototype|toString|valueOf)$/,
toString = Object.prototype.toString,
isArray = Array.isArray = Array.isArray || function(obj) {
return toString.call(obj) === '[object Array]';
},
proto = Array.prototype,
slice = proto.slice,
forEach = proto.forEach || function(iter, bind) {
for (var i = 0, l = this.length; i < l; i++)
iter.call(bind, this[i], i, this);
},
forIn = function(iter, bind) {
// Do not use Object.keys for iteration as iterators might modify
// the object we're iterating over, making the hasOwnProperty still
@ -38,54 +37,50 @@ var Base = new function() {
if (this.hasOwnProperty(i))
iter.call(bind, this[i], i, this);
},
// A ahort cut to a simplified version of Object.create that only
isArray = Array.isArray = Array.isArray || function(obj) {
return toString.call(obj) === '[object Array]';
},
// A short-cut to a simplified version of Object.create that only
// supports the first parameter (in the emulation):
create = Object.create || function(proto) {
// From all browsers that do not offer Object.create(), we only
// support Firefox 3.5 & 3.6, and this hack works there:
return { __proto__: proto };
},
_define = Object.defineProperty,
_describe = Object.getOwnPropertyDescriptor;
function define(obj, name, desc) {
try {
// Unfortunately Safari seems to ignore configurable: true and does
describe = Object.getOwnPropertyDescriptor || function(obj, name) {
// Emulate Object.getOwnPropertyDescriptor for outdated browsers
var get = obj.__lookupGetter__ && obj.__lookupGetter__(name);
return get
? { get: get, set: obj.__lookupSetter__(name),
enumerable: true, configurable: true }
: obj.hasOwnProperty(name)
? { value: obj[name], enumerable: true,
configurable: true, writable: true }
: null;
},
_define = Object.defineProperty || function(obj, name, desc) {
// Emulate Object.defineProperty for outdated browsers
if ((desc.get || desc.set) && obj.__defineGetter__) {
if (desc.get)
obj.__defineGetter__(name, desc.get);
if (desc.set)
obj.__defineSetter__(name, desc.set);
} else {
obj[name] = desc.value;
}
return obj;
},
define = function(obj, name, desc) {
// Unfortunately WebKit seems to ignore configurable: true and does
// not override existing properties, so we need to delete first:
delete obj[name];
return _define(obj, name, desc);
} catch (e) {}
// Emulate Object.defineProperty for outdated browsers.
// NOTE: We're also falling back on this scenario currently when the
// above trigggers an exception, e.g. when using Base.define on the
// window object.
if ((desc.get || desc.set) && obj.__defineGetter__) {
if (desc.get)
obj.__defineGetter__(name, desc.get);
if (desc.set)
obj.__defineSetter__(name, desc.set);
} else {
obj[name] = desc.value;
}
return obj;
}
function describe(obj, name) {
try {
return _describe(obj, name);
} catch (e) {}
// Emulate Object.getOwnPropertyDescriptor for outdated browsers
// NOTE: We're also falling back on this scenario currently when the
// above trigggers an exception.
var get = obj.__lookupGetter__ && obj.__lookupGetter__(name);
return get
? { get: get, set: obj.__lookupSetter__(name),
enumerable: true, configurable: true }
: obj.hasOwnProperty(name)
? { value: obj[name], writable: true ,
enumerable: true, configurable: true }
: null;
}
};
/**
* Private function that injects functions from src into dest, overriding