diff --git a/es5-shim.js b/es5-shim.js index 8dd43889..49b02544 100644 --- a/es5-shim.js +++ b/es5-shim.js @@ -1520,15 +1520,13 @@ defineProperties(StringPrototype, { // ES5 15.5.4.20 // whitespace from: http://es5.github.io/#x15.5.4.20 var ws = '\t\n\v\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005' + - '\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF'; -var nextLine = '\x85'; -var zeroWidth = '\u200B'; + '\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u202F\u205F\u3000\uFEFF'; +var nxtLine = '\x85'; var wsRegexChars = '[' + ws + '][' + ws + ']*'; var trimBeginRegexp = new RegExp('^' + wsRegexChars); var trimEndRegexp = new RegExp(wsRegexChars + '$'); var hasTrimWhitespaceBug = 'trim' in StringPrototype && - typeof StringPrototype.trim === 'function' && - (ws.trim() || !nextLine.trim() || !zeroWidth.trim()); + typeof StringPrototype.trim === 'function' && (ws.trim() || !nxtLine.trim()); defineProperties(StringPrototype, { // http://blog.stevenlevithan.com/archives/faster-trim-javascript // http://perfectionkills.com/whitespace-deviations/ diff --git a/tests/spec/s-string.js b/tests/spec/s-string.js index 8543b5ef..6b66947e 100644 --- a/tests/spec/s-string.js +++ b/tests/spec/s-string.js @@ -4,7 +4,9 @@ describe('String', function () { 'use strict'; describe('trim', function () { - var test = '\t\n\v\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFFHello, World!\t\n\v\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF'; + var wsp = '\t\n\v\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005' + + '\u2006\u2007\u2008\u2009\u200A\u200B\u2028\u2029\u202F\u205F\u3000\uFEFF'; + var test = [wsp, 'Hello, World!', wsp].join(''); it('trims all ES5 whitespace', function () { expect(test.trim()).toEqual('Hello, World!'); @@ -15,11 +17,6 @@ describe('String', function () { expect('\x85'.trim()).toBe('\x85'); expect('\x85'.trim().length).toBe(1); }); - - it('does not trim the zero-width space', function () { - expect('\u200B'.trim()).toBe('\u200B'); - expect('\u200B'.trim().length).toBe(1); - }); }); describe('replace', function () {