Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2783 closed defect (duplicate)

[CLA] dojo.number.parse fails for negative numbers in IE

Reported by: msmith@… Owned by: Adam Peller
Priority: high Milestone:
Component: Core Version: 0.9
Keywords: Cc: Adam Peller
Blocked By: Blocking:

Description

The 0.9 tests show that dojo.number.parse fails on negative numbers when running in IE. The cause of the problem is in the assumption that the RegExp? results array will return an undefined value for results[1] when parsing a negative number. However, in IE, the RegExp? returns an empty string in this situation. The problem can be solved by modifying the if statement in dojo.number.parse to look for empty strings as well.

Sorry I don't have a universal diff format, but here's how to apply the fix:

number.js; dojo.number.parse() Change:

if(typeof absoluteMatch == 'undefined'){

matched the negative pattern absoluteMatch = results[2]; info.factor *= -1;

}

To:

if(typeof absoluteMatch == 'undefined'
absoluteMatch == ""){

matched the negative pattern absoluteMatch = results[2]; info.factor *= -1;

}

Submitted by: Michael Smith (msmith) [CLA, but don't have a trac account yet]

Change History (4)

comment:1 Changed 12 years ago by guest

Whoops, I didn't mark the code as preformatted text. Here's another try:

number.js; dojo.number.parse()

Change:

    if(typeof absoluteMatch == 'undefined'){
        // matched the negative pattern
        absoluteMatch = results[2];
        info.factor *= -1;
    }

To:

    if(typeof absoluteMatch == 'undefined' || absoluteMatch == ""){
        // matched the negative pattern
        absoluteMatch = results[2];
        info.factor *= -1;
    }

~msmith

comment:2 Changed 12 years ago by Adam Peller

Milestone: 0.9M2
Owner: changed from anonymous to Adam Peller
Priority: normalhigh
Reporter: changed from guest to msmith@…

comment:3 Changed 12 years ago by Adam Peller

Resolution: duplicate
Status: newclosed

Fixed by #2878

comment:4 Changed 12 years ago by (none)

Milestone: 0.9M2

Milestone 0.9M2 deleted

Note: See TracTickets for help on using tickets.