clientside / amplesdk

Ample SDK - JavaScript UI Framework
Other
170 stars 29 forks source link

'toFixed' rounds 0 to 0.21 when string parameter is provided #169

Closed amoilanen closed 11 years ago

amoilanen commented 11 years ago

When used with a String parameter 'toFixed' produces wrong results for 0:

    test("Rounding numbers", function () {
        var zero = 0;

        equal("0.00", zero.toFixed(2));

        //Fails, the result is "0.21"
        equal("0.00", zero.toFixed("2"));
    });

The second test case fails. I understand that we should provide a number parameter rather than a String, but with the latest IE, Firefox and Chrome both test cases pass so the compatibility with this common browser behavior can be desirable.

ilinsky commented 11 years ago

Fixed per rev 5cddc79b705a2b81d890c165872910389dcc0917 Also fixed erratic test (0.6).toFixed(1) != '1' that let ample implementation redefine well working native toFixed. Now should only apply in IE before 9