augment.js
augment.js copied to clipboard
Potential edge case bugs
https://gist.github.com/1120592
Lists a bunch of bugs that are in various implementations of ES5 shims. You may want to thoroughly check yours does not fail any.
For example
String#trim
using buggy character class \s instead of explicitly defining whitespace/line terminators
Note that \s fails in IE sometimes (because IE, rage.)
Yeah I saw that gist, very useful.
I looked at the string trim issue, I decided not to include that in this release because I want to do a bit more testing around it.
Checking in chrome the native implementation seems to fail on some of those whitespace like characters, which is confusing because according to Kangax's article seems to imply that chrome shouldn't fail.
I'll spend some more time looking into this though as I would like augment to be close to agree with the spec where possible/reasonable.
For what its worth this is the test (adapted from es5-shim) that I had that failed in chrome:
test("handling all unicode characters deemed as whitespace by the spec", function () {
var str = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF";
equal("Hello World!", str.trim(), "should remove all white space characters as defined by the spec")
})
Interesting. Can't trust those browsers :(.
Good job on the whole making it spec compliant thing though o/
I think I remember seeing Chrome fail test-262 tests for whitespace in trim.