String.charAt()
Maciej Stachowiak
mjs at apple.com
Sun Apr 17 21:04:15 CEST 2005
On Apr 16, 2005, at 10:53 AM, Harri Porten wrote:
> Hi!
>
> I just saw a comment in JavaScriptCore's String implementation that
> confused by slightly:
>
> case CharAt:
> // Other browsers treat an omitted parameter as 0 rather than NaN.
> // That doesn't match the ECMA standard, but is needed for site
> compatibility.
> dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
>
> I think you can remove that comment as it is wrong. It's not only
> other
> browsers but also the standard that treat a missing parameter as 0.
> That's because toInteger(undefined) is supposed to return 0
> (9.4/2). You
> might want to reevaluate how your toInteger() implementation works
> or at
> least check all places where it is used.
>
Yeah this seems like a bug in the toInteger() implementation. Ours
just uses toNumber and rounds the result, which seems wrong at least
in this one case.
Regards,
Maciej
More information about the Khtml-devel
mailing list