+2004-09-26 Darin Adler <darin@apple.com>
+
+ - refine charAt/charCodeAt fix slightly
+
+ * kjs/string_object.cpp: (StringProtoFuncImp::call): Treat undefined the same was as an
+ omitted parameter, as we do everywhere else, and as other browsers do here.
+
2004-09-26 Darin Adler <darin@apple.com>
Reviewed by Kevin.
// handled above
break;
case CharAt:
- // WinIE treats omitted parameter as 0 rather than NaN.
+ // 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 = args.size() == 0 ? 0 : a0.toInteger(exec);
+ dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
if (dpos >= 0 && dpos < len) // false for NaN
u = s.substr(static_cast<int>(dpos), 1);
else
result = String(u);
break;
case CharCodeAt:
- // WinIE treats omitted parameter as 0 rather than NaN.
+ // 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 = args.size() == 0 ? 0 : a0.toInteger(exec);
+ dpos = a0.isA(UndefinedType) ? 0 : a0.toInteger(exec);
if (dpos >= 0 && dpos < len) { // false for NaN
UChar c = s[static_cast<int>(dpos)];
d = (c.high() << 8) + c.low();