From 61b0aa944bbacf6e5b4ff4e3528c2b5b77f018f1 Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 17 Feb 2013 18:31:57 +0400 Subject: [PATCH] do not modify string split on chrome --- lib/ace/lib/es5-shim.js | 46 +---------------------------------------- 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/lib/ace/lib/es5-shim.js b/lib/ace/lib/es5-shim.js index 46a45ffe..217bdc61 100644 --- a/lib/ace/lib/es5-shim.js +++ b/lib/ace/lib/es5-shim.js @@ -982,45 +982,6 @@ if (!Date.now) { // ====== // - -// ES5 15.5.4.14 -// http://es5.github.com/#x15.5.4.14 -// [bugfix, chrome] -// If separator is undefined, then the result array contains just one String, -// which is the this value (converted to a String). If limit is not undefined, -// then the output array is truncated so that it contains no more than limit -// elements. -// "0".split(undefined, 0) -> [] -if("0".split(void 0, 0).length) { - var string_split = String.prototype.split; - String.prototype.split = function(separator, limit) { - if(separator === void 0 && limit === 0)return []; - return string_split.apply(this, arguments); - } -} - -// ECMA-262, 3rd B.2.3 -// Note an ECMAScript standart, although ECMAScript 3rd Edition has a -// non-normative section suggesting uniform semantics and it should be -// normalized across all browsers -// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE -if("".substr && "0b".substr(-1) !== "b") { - var string_substr = String.prototype.substr; - /** - * Get the substring of a string - * @param {integer} start where to start the substring - * @param {integer} length how many characters to return - * @return {string} - */ - String.prototype.substr = function(start, length) { - return string_substr.call( - this, - start < 0 ? (start = this.length + start) < 0 ? 0 : start : start, - length - ); - } -} - // ES5 15.5.4.20 // http://es5.github.com/#x15.5.4.20 var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + @@ -1033,12 +994,7 @@ if (!String.prototype.trim || ws.trim()) { var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), trimEndRegexp = new RegExp(ws + ws + "*$"); String.prototype.trim = function trim() { - if (this === undefined || this === null) { - throw new TypeError("can't convert "+this+" to object"); - } - return String(this) - .replace(trimBeginRegexp, "") - .replace(trimEndRegexp, ""); + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); }; }