123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- (function (definition) {
-
- if (typeof define == "function") {
- define(definition);
-
- } else if (typeof YUI == "function") {
- YUI.add("es5-sham", definition);
-
- } else {
- definition();
- }
- })(function () {
- if (!Object.getPrototypeOf) {
-
-
-
- Object.getPrototypeOf = function getPrototypeOf(object) {
- return object.__proto__ || (
- object.constructor
- ? object.constructor.prototype
- : prototypeOfObject
- );
- };
- }
- var call = Function.prototype.call;
- var prototypeOfObject = Object.prototype;
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
- var supportsAccessors;
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
- }
- if (!Object.getOwnPropertyDescriptor) {
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
- if ((typeof object != "object" && typeof object != "function") || object === null) {
- throw new TypeError(ERR_NON_OBJECT + object);
- }
-
- if (!owns(object, property)) {
- return;
- }
-
-
- var descriptor = { enumerable: true, configurable: true };
-
-
- if (supportsAccessors) {
-
-
-
-
-
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
- var getter = lookupGetter(object, property);
- var setter = lookupSetter(object, property);
-
- object.__proto__ = prototype;
- if (getter || setter) {
- if (getter) {
- descriptor.get = getter;
- }
- if (setter) {
- descriptor.set = setter;
- }
-
-
- return descriptor;
- }
- }
-
-
- descriptor.value = object[property];
- return descriptor;
- };
- }
- if (!Object.getOwnPropertyNames) {
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
- return Object.keys(object);
- };
- }
- if (!Object.create) {
- Object.create = function create(prototype, properties) {
- var object;
- function Type() {}
- if (prototype === null) {
- object = { "__proto__": null };
- } else {
- if (typeof prototype !== "object" && typeof prototype !== "function") {
-
-
-
-
-
- throw new TypeError("Object prototype may only be an Object or null");
- }
- Type.prototype = prototype;
- object = new Type();
-
-
-
-
- object.__proto__ = prototype;
- }
- if (properties !== void 0) {
- Object.defineProperties(object, properties);
- }
- return object;
- };
- }
- function doesDefinePropertyWork(object) {
- try {
- Object.defineProperty(object, "sentinel", {});
- return "sentinel" in object;
- } catch (exception) {
-
- }
- }
- if (Object.defineProperty) {
- var definePropertyWorksOnObject = doesDefinePropertyWork({});
- var definePropertyWorksOnDom = typeof document == "undefined" ||
- doesDefinePropertyWork(document.createElement("div"));
- if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
- var definePropertyFallback = Object.defineProperty;
- }
- }
- if (!Object.defineProperty || definePropertyFallback) {
- var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
- var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
- var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
- "on this javascript engine";
- Object.defineProperty = function defineProperty(object, property, descriptor) {
- if ((typeof object != "object" && typeof object != "function") || object === null) {
- throw new TypeError(ERR_NON_OBJECT_TARGET + object);
- }
- if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) {
- throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
- }
-
-
- if (definePropertyFallback) {
- try {
- return definePropertyFallback.call(Object, object, property, descriptor);
- } catch (exception) {
-
- }
- }
-
- if (owns(descriptor, "value")) {
-
-
-
- if (supportsAccessors && (lookupGetter(object, property) ||
- lookupSetter(object, property)))
- {
-
-
-
-
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
-
-
- delete object[property];
- object[property] = descriptor.value;
-
- object.__proto__ = prototype;
- } else {
- object[property] = descriptor.value;
- }
- } else {
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
-
- if (owns(descriptor, "get")) {
- defineGetter(object, property, descriptor.get);
- }
- if (owns(descriptor, "set")) {
- defineSetter(object, property, descriptor.set);
- }
- }
- return object;
- };
- }
- if (!Object.defineProperties) {
- Object.defineProperties = function defineProperties(object, properties) {
- for (var property in properties) {
- if (owns(properties, property) && property != "__proto__") {
- Object.defineProperty(object, property, properties[property]);
- }
- }
- return object;
- };
- }
- if (!Object.seal) {
- Object.seal = function seal(object) {
-
-
-
- return object;
- };
- }
- if (!Object.freeze) {
- Object.freeze = function freeze(object) {
-
-
-
- return object;
- };
- }
- try {
- Object.freeze(function () {});
- } catch (exception) {
- Object.freeze = (function freeze(freezeObject) {
- return function freeze(object) {
- if (typeof object == "function") {
- return object;
- } else {
- return freezeObject(object);
- }
- };
- })(Object.freeze);
- }
- if (!Object.preventExtensions) {
- Object.preventExtensions = function preventExtensions(object) {
-
-
-
- return object;
- };
- }
- if (!Object.isSealed) {
- Object.isSealed = function isSealed(object) {
- return false;
- };
- }
- if (!Object.isFrozen) {
- Object.isFrozen = function isFrozen(object) {
- return false;
- };
- }
- if (!Object.isExtensible) {
- Object.isExtensible = function isExtensible(object) {
-
- if (Object(object) !== object) {
- throw new TypeError();
- }
-
- var name = '';
- while (owns(object, name)) {
- name += '?';
- }
- object[name] = true;
- var returnValue = owns(object, name);
- delete object[name];
- return returnValue;
- };
- }
- });
|