Open anba opened 10 years ago
@mathiasbynens FYI
Thanks for the detailed report.
@anba Awesome feedback, as usual :) I’ll get these fixed. Thanks!
You're welcome! And since I'm re-using parts of the traceur test suite for my own project, it's only fair to file bug reports every now and then. ^^
@anba Actually, the tests for the first three bugs you reported were taken from http://mths.be/startswith, http://mths.be/endswith, and http://mths.be/contains. I just happened to contribute them to Traceur :)
I’ve fixed the issues you mentioned in those three projects and will be submitting patches to Traceur as soon as possible.
FWIW, in environments where Object.prototype.toString
or String.prototype.indexOf
is overridden, most of these polyfills will fail too. Not sure if that’s something we need to guard against. @arv, any thoughts?
@mathiasbynens I was considering creating a module that captures these as early as possible.
The new String polyfills are not completely spec compliant for certain edge cases.
Two issues in
String.prototype.startsWith
:ToString(this Argument)
arguments[1]
needs to bearguments.length > 1 ? arguments[1] : undefined
b/c of inherited properties fromObject.prototype
One issue in
String.prototype.endsWith
:ToString(this Argument)
One issue in
String.prototype.contains
:arguments[1]
needs to bearguments.length > 1 ? arguments[1] : undefined
b/c of inherited properties fromObject.prototype
Three issues in
String.raw
:ToObject(raw)
must be performed only onceToUint32()
needs to be replaced withToLength()
Array.prototype
Simple test cases for each issue:
Expected: throws
0
Actual: throws TypeErrorExpected: returns true Actual: returns false
Expected: throws
0
Actual: throws TypeErrorExpected: returns true Actual: returns false
Expected: "" Actual: throws
Error("missing ToObject")
Expected: returns "" Actual: most likely causes an out-of-memory error in browsers...
Expected: "a!b" Actual: "aundefinedb"