forked from Wavyzz/dolibarr
Upgrade ACE Editor from 1.4.7 to 1.4.14
This commit is contained in:
@@ -209,7 +209,6 @@ window.onmessage = function(e) {
|
||||
}
|
||||
else if (msg.init) {
|
||||
window.initBaseUrls(msg.tlns);
|
||||
require("ace/lib/es5-shim");
|
||||
sender = window.sender = window.initSender();
|
||||
var clazz = require(msg.module)[msg.classname];
|
||||
main = window.main = new clazz(sender);
|
||||
@@ -787,8 +786,8 @@ EventEmitter._signal = function(eventName, e) {
|
||||
|
||||
EventEmitter.once = function(eventName, callback) {
|
||||
var _self = this;
|
||||
this.addEventListener(eventName, function newCallback() {
|
||||
_self.removeEventListener(eventName, newCallback);
|
||||
this.on(eventName, function newCallback() {
|
||||
_self.off(eventName, newCallback);
|
||||
callback.apply(null, arguments);
|
||||
});
|
||||
if (!callback) {
|
||||
@@ -860,7 +859,9 @@ EventEmitter.removeEventListener = function(eventName, callback) {
|
||||
};
|
||||
|
||||
EventEmitter.removeAllListeners = function(eventName) {
|
||||
if (this._eventRegistry) this._eventRegistry[eventName] = [];
|
||||
if (!eventName) this._eventRegistry = this._defaultHandlers = undefined;
|
||||
if (this._eventRegistry) this._eventRegistry[eventName] = undefined;
|
||||
if (this._defaultHandlers) this._defaultHandlers[eventName] = undefined;
|
||||
};
|
||||
|
||||
exports.EventEmitter = EventEmitter;
|
||||
@@ -960,7 +961,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
||||
});
|
||||
};
|
||||
this.detach = function() {
|
||||
this.document.removeEventListener("change", this.$onChange);
|
||||
this.document.off("change", this.$onChange);
|
||||
};
|
||||
this.attach = function(doc) {
|
||||
this.document = doc || this.document;
|
||||
@@ -1292,6 +1293,16 @@ var Document = function(textOrLines) {
|
||||
}
|
||||
};
|
||||
|
||||
this.$safeApplyDelta = function(delta) {
|
||||
var docLength = this.$lines.length;
|
||||
if (
|
||||
delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
|
||||
|| delta.action == "insert" && delta.start.row <= docLength
|
||||
) {
|
||||
this.applyDelta(delta);
|
||||
}
|
||||
};
|
||||
|
||||
this.$splitAndapplyLargeDelta = function(delta, MAX) {
|
||||
var lines = delta.lines;
|
||||
var l = lines.length - MAX + 1;
|
||||
@@ -1314,7 +1325,7 @@ var Document = function(textOrLines) {
|
||||
this.applyDelta(delta, true);
|
||||
};
|
||||
this.revertDelta = function(delta) {
|
||||
this.applyDelta({
|
||||
this.$safeApplyDelta({
|
||||
start: this.clonePos(delta.start),
|
||||
end: this.clonePos(delta.end),
|
||||
action: (delta.action == "insert" ? "remove" : "insert"),
|
||||
@@ -3195,700 +3206,3 @@ oop.inherits(Worker, Mirror);
|
||||
}).call(Worker.prototype);
|
||||
|
||||
});
|
||||
|
||||
define("ace/lib/es5-shim",[], function(require, exports, module) {
|
||||
|
||||
function Empty() {}
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
Function.prototype.bind = function bind(that) { // .length is 1
|
||||
var target = this;
|
||||
if (typeof target != "function") {
|
||||
throw new TypeError("Function.prototype.bind called on incompatible " + target);
|
||||
}
|
||||
var args = slice.call(arguments, 1); // for normal call
|
||||
var bound = function () {
|
||||
|
||||
if (this instanceof bound) {
|
||||
|
||||
var result = target.apply(
|
||||
this,
|
||||
args.concat(slice.call(arguments))
|
||||
);
|
||||
if (Object(result) === result) {
|
||||
return result;
|
||||
}
|
||||
return this;
|
||||
|
||||
} else {
|
||||
return target.apply(
|
||||
that,
|
||||
args.concat(slice.call(arguments))
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
if(target.prototype) {
|
||||
Empty.prototype = target.prototype;
|
||||
bound.prototype = new Empty();
|
||||
Empty.prototype = null;
|
||||
}
|
||||
return bound;
|
||||
};
|
||||
}
|
||||
var call = Function.prototype.call;
|
||||
var prototypeOfArray = Array.prototype;
|
||||
var prototypeOfObject = Object.prototype;
|
||||
var slice = prototypeOfArray.slice;
|
||||
var _toString = call.bind(prototypeOfObject.toString);
|
||||
var owns = call.bind(prototypeOfObject.hasOwnProperty);
|
||||
var defineGetter;
|
||||
var defineSetter;
|
||||
var lookupGetter;
|
||||
var lookupSetter;
|
||||
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 ([1,2].splice(0).length != 2) {
|
||||
if(function() { // test IE < 9 to splice bug - see issue #138
|
||||
function makeArray(l) {
|
||||
var a = new Array(l+2);
|
||||
a[0] = a[1] = 0;
|
||||
return a;
|
||||
}
|
||||
var array = [], lengthBefore;
|
||||
|
||||
array.splice.apply(array, makeArray(20));
|
||||
array.splice.apply(array, makeArray(26));
|
||||
|
||||
lengthBefore = array.length; //46
|
||||
array.splice(5, 0, "XXX"); // add one element
|
||||
|
||||
lengthBefore + 1 == array.length
|
||||
|
||||
if (lengthBefore + 1 == array.length) {
|
||||
return true;// has right splice implementation without bugs
|
||||
}
|
||||
}()) {//IE 6/7
|
||||
var array_splice = Array.prototype.splice;
|
||||
Array.prototype.splice = function(start, deleteCount) {
|
||||
if (!arguments.length) {
|
||||
return [];
|
||||
} else {
|
||||
return array_splice.apply(this, [
|
||||
start === void 0 ? 0 : start,
|
||||
deleteCount === void 0 ? (this.length - start) : deleteCount
|
||||
].concat(slice.call(arguments, 2)))
|
||||
}
|
||||
};
|
||||
} else {//IE8
|
||||
Array.prototype.splice = function(pos, removeCount){
|
||||
var length = this.length;
|
||||
if (pos > 0) {
|
||||
if (pos > length)
|
||||
pos = length;
|
||||
} else if (pos == void 0) {
|
||||
pos = 0;
|
||||
} else if (pos < 0) {
|
||||
pos = Math.max(length + pos, 0);
|
||||
}
|
||||
|
||||
if (!(pos+removeCount < length))
|
||||
removeCount = length - pos;
|
||||
|
||||
var removed = this.slice(pos, pos+removeCount);
|
||||
var insert = slice.call(arguments, 2);
|
||||
var add = insert.length;
|
||||
if (pos === length) {
|
||||
if (add) {
|
||||
this.push.apply(this, insert);
|
||||
}
|
||||
} else {
|
||||
var remove = Math.min(removeCount, length - pos);
|
||||
var tailOldPos = pos + remove;
|
||||
var tailNewPos = tailOldPos + add - remove;
|
||||
var tailCount = length - tailOldPos;
|
||||
var lengthAfterRemove = length - remove;
|
||||
|
||||
if (tailNewPos < tailOldPos) { // case A
|
||||
for (var i = 0; i < tailCount; ++i) {
|
||||
this[tailNewPos+i] = this[tailOldPos+i];
|
||||
}
|
||||
} else if (tailNewPos > tailOldPos) { // case B
|
||||
for (i = tailCount; i--; ) {
|
||||
this[tailNewPos+i] = this[tailOldPos+i];
|
||||
}
|
||||
} // else, add == remove (nothing to do)
|
||||
|
||||
if (add && pos === lengthAfterRemove) {
|
||||
this.length = lengthAfterRemove; // truncate array
|
||||
this.push.apply(this, insert);
|
||||
} else {
|
||||
this.length = lengthAfterRemove + add; // reserves space
|
||||
for (i = 0; i < add; ++i) {
|
||||
this[pos+i] = insert[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
};
|
||||
}
|
||||
}
|
||||
if (!Array.isArray) {
|
||||
Array.isArray = function isArray(obj) {
|
||||
return _toString(obj) == "[object Array]";
|
||||
};
|
||||
}
|
||||
var boxedString = Object("a"),
|
||||
splitString = boxedString[0] != "a" || !(0 in boxedString);
|
||||
|
||||
if (!Array.prototype.forEach) {
|
||||
Array.prototype.forEach = function forEach(fun /*, thisp*/) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
thisp = arguments[1],
|
||||
i = -1,
|
||||
length = self.length >>> 0;
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(); // TODO message
|
||||
}
|
||||
|
||||
while (++i < length) {
|
||||
if (i in self) {
|
||||
fun.call(thisp, self[i], i, object);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.map) {
|
||||
Array.prototype.map = function map(fun /*, thisp*/) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0,
|
||||
result = Array(length),
|
||||
thisp = arguments[1];
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (i in self)
|
||||
result[i] = fun.call(thisp, self[i], i, object);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.filter) {
|
||||
Array.prototype.filter = function filter(fun /*, thisp */) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0,
|
||||
result = [],
|
||||
value,
|
||||
thisp = arguments[1];
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (i in self) {
|
||||
value = self[i];
|
||||
if (fun.call(thisp, value, i, object)) {
|
||||
result.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.every) {
|
||||
Array.prototype.every = function every(fun /*, thisp */) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0,
|
||||
thisp = arguments[1];
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (i in self && !fun.call(thisp, self[i], i, object)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.some) {
|
||||
Array.prototype.some = function some(fun /*, thisp */) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0,
|
||||
thisp = arguments[1];
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (i in self && fun.call(thisp, self[i], i, object)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.reduce) {
|
||||
Array.prototype.reduce = function reduce(fun /*, initial*/) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0;
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
if (!length && arguments.length == 1) {
|
||||
throw new TypeError("reduce of empty array with no initial value");
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
var result;
|
||||
if (arguments.length >= 2) {
|
||||
result = arguments[1];
|
||||
} else {
|
||||
do {
|
||||
if (i in self) {
|
||||
result = self[i++];
|
||||
break;
|
||||
}
|
||||
if (++i >= length) {
|
||||
throw new TypeError("reduce of empty array with no initial value");
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
for (; i < length; i++) {
|
||||
if (i in self) {
|
||||
result = fun.call(void 0, result, self[i], i, object);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.reduceRight) {
|
||||
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
|
||||
var object = toObject(this),
|
||||
self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
object,
|
||||
length = self.length >>> 0;
|
||||
if (_toString(fun) != "[object Function]") {
|
||||
throw new TypeError(fun + " is not a function");
|
||||
}
|
||||
if (!length && arguments.length == 1) {
|
||||
throw new TypeError("reduceRight of empty array with no initial value");
|
||||
}
|
||||
|
||||
var result, i = length - 1;
|
||||
if (arguments.length >= 2) {
|
||||
result = arguments[1];
|
||||
} else {
|
||||
do {
|
||||
if (i in self) {
|
||||
result = self[i--];
|
||||
break;
|
||||
}
|
||||
if (--i < 0) {
|
||||
throw new TypeError("reduceRight of empty array with no initial value");
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
do {
|
||||
if (i in this) {
|
||||
result = fun.call(void 0, result, self[i], i, object);
|
||||
}
|
||||
} while (i--);
|
||||
|
||||
return result;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
|
||||
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
|
||||
var self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
toObject(this),
|
||||
length = self.length >>> 0;
|
||||
|
||||
if (!length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
if (arguments.length > 1) {
|
||||
i = toInteger(arguments[1]);
|
||||
}
|
||||
i = i >= 0 ? i : Math.max(0, length + i);
|
||||
for (; i < length; i++) {
|
||||
if (i in self && self[i] === sought) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
|
||||
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
|
||||
var self = splitString && _toString(this) == "[object String]" ?
|
||||
this.split("") :
|
||||
toObject(this),
|
||||
length = self.length >>> 0;
|
||||
|
||||
if (!length) {
|
||||
return -1;
|
||||
}
|
||||
var i = length - 1;
|
||||
if (arguments.length > 1) {
|
||||
i = Math.min(i, toInteger(arguments[1]));
|
||||
}
|
||||
i = i >= 0 ? i : length - Math.abs(i);
|
||||
for (; i >= 0; i--) {
|
||||
if (i in self && sought === self[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
if (!Object.getPrototypeOf) {
|
||||
Object.getPrototypeOf = function getPrototypeOf(object) {
|
||||
return object.__proto__ || (
|
||||
object.constructor ?
|
||||
object.constructor.prototype :
|
||||
prototypeOfObject
|
||||
);
|
||||
};
|
||||
}
|
||||
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, getter, setter;
|
||||
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) {
|
||||
var createEmpty;
|
||||
if (Object.prototype.__proto__ === null) {
|
||||
createEmpty = function () {
|
||||
return { "__proto__": null };
|
||||
};
|
||||
} else {
|
||||
createEmpty = function () {
|
||||
var empty = {};
|
||||
for (var i in empty)
|
||||
empty[i] = null;
|
||||
empty.constructor =
|
||||
empty.hasOwnProperty =
|
||||
empty.propertyIsEnumerable =
|
||||
empty.isPrototypeOf =
|
||||
empty.toLocaleString =
|
||||
empty.toString =
|
||||
empty.valueOf =
|
||||
empty.__proto__ = null;
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
|
||||
Object.create = function create(prototype, properties) {
|
||||
var object;
|
||||
if (prototype === null) {
|
||||
object = createEmpty();
|
||||
} else {
|
||||
if (typeof prototype != "object")
|
||||
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
|
||||
var Type = function () {};
|
||||
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))
|
||||
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(); // TODO message
|
||||
}
|
||||
var name = '';
|
||||
while (owns(object, name)) {
|
||||
name += '?';
|
||||
}
|
||||
object[name] = true;
|
||||
var returnValue = owns(object, name);
|
||||
delete object[name];
|
||||
return returnValue;
|
||||
};
|
||||
}
|
||||
if (!Object.keys) {
|
||||
var hasDontEnumBug = true,
|
||||
dontEnums = [
|
||||
"toString",
|
||||
"toLocaleString",
|
||||
"valueOf",
|
||||
"hasOwnProperty",
|
||||
"isPrototypeOf",
|
||||
"propertyIsEnumerable",
|
||||
"constructor"
|
||||
],
|
||||
dontEnumsLength = dontEnums.length;
|
||||
|
||||
for (var key in {"toString": null}) {
|
||||
hasDontEnumBug = false;
|
||||
}
|
||||
|
||||
Object.keys = function keys(object) {
|
||||
|
||||
if (
|
||||
(typeof object != "object" && typeof object != "function") ||
|
||||
object === null
|
||||
) {
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
}
|
||||
|
||||
var keys = [];
|
||||
for (var name in object) {
|
||||
if (owns(object, name)) {
|
||||
keys.push(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
|
||||
var dontEnum = dontEnums[i];
|
||||
if (owns(object, dontEnum)) {
|
||||
keys.push(dontEnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
}
|
||||
if (!Date.now) {
|
||||
Date.now = function now() {
|
||||
return new Date().getTime();
|
||||
};
|
||||
}
|
||||
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003" +
|
||||
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
|
||||
"\u2029\uFEFF";
|
||||
if (!String.prototype.trim) {
|
||||
ws = "[" + ws + "]";
|
||||
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
|
||||
trimEndRegexp = new RegExp(ws + ws + "*$");
|
||||
String.prototype.trim = function trim() {
|
||||
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
|
||||
};
|
||||
}
|
||||
|
||||
function toInteger(n) {
|
||||
n = +n;
|
||||
if (n !== n) { // isNaN
|
||||
n = 0;
|
||||
} else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
|
||||
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
function isPrimitive(input) {
|
||||
var type = typeof input;
|
||||
return (
|
||||
input === null ||
|
||||
type === "undefined" ||
|
||||
type === "boolean" ||
|
||||
type === "number" ||
|
||||
type === "string"
|
||||
);
|
||||
}
|
||||
|
||||
function toPrimitive(input) {
|
||||
var val, valueOf, toString;
|
||||
if (isPrimitive(input)) {
|
||||
return input;
|
||||
}
|
||||
valueOf = input.valueOf;
|
||||
if (typeof valueOf === "function") {
|
||||
val = valueOf.call(input);
|
||||
if (isPrimitive(val)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
toString = input.toString;
|
||||
if (typeof toString === "function") {
|
||||
val = toString.call(input);
|
||||
if (isPrimitive(val)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
throw new TypeError();
|
||||
}
|
||||
var toObject = function (o) {
|
||||
if (o == null) { // this matches both null and undefined
|
||||
throw new TypeError("can't convert "+o+" to object");
|
||||
}
|
||||
return Object(o);
|
||||
};
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user