If no argument is passed to String.prototype.localeCompare, the function returns 0 no matter what the string obtained from this is.
According to ES5 clause 15, fourth paragraph, "if a function or constructor described in this clause is given fewer arguments than the function is specified to require, the function or constructor shall behave exactly as if it had been given sufficient additional arguments, each such argument being the undefined value."
ToString(undefined) is "undefined", so the function should treat a missing first argument as that string.
Current versions of Safari, Chrome, and Opera have the same bug; Internet Explorer 9 follows the specification.
Created attachment 711188 [details] [diff] [review]
I'd rather fix this separately than as a side effect of implementing the ECMAScript Internationalization API Specification.
I'm also adding a test case to test262, the ECMA-262 conformance test suite. For more information, see
Comment on attachment 711188 [details] [diff] [review]
Review of attachment 711188 [details] [diff] [review]:
Yeah, this definitely should get pulled out of all that. Two little things to fix and this is fine.
@@ +1,1 @@
> +assertEq("a".localeCompare(), "a".localeCompare("undefined"));
to better test the actual implemented behavior here.
@@ +783,1 @@
> return true;
Uh...this should be return false. I'm not sure how that got there before!
Created attachment 711615 [details] [diff] [review]
Updated per comment 2. Carrying r+jwalden.
Comment on attachment 711615 [details] [diff] [review]
I've added this bug to the compatibility doc. Please correct the info if I'm wrong.