Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10617 closed bug (worksforme)

Type coersion wrongly placed

Reported by: anonymous Owned by: Rick Waldron
Priority: low Milestone: 1.next
Component: css Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:


Please take a look at this line of code:

value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );


+( ret[1] + 1)

Type coercion is done *outside* the brackets. But this doesn't make sense because if ret[1] is not a number then ret[1] + 1 does the wrong thing. If ret[1] is a number then the type coercion does nothing.

Change History (3)

comment:1 Changed 11 years ago by Rick Waldron

Component: unfiledcss
Milestone: None1.next
Owner: set to Rick Waldron
Priority: undecidedlow
Status: newassigned

Good catch. Patch to follow

comment:2 Changed 11 years ago by mikesherov

Resolution: worksforme
Status: assignedclosed

No, this is the correct behavior!

+( ret[1] + 1)

in this case, ret[1] is the string "+" or "-", to which 1 is added as string. This makes the resulting string "+1" or "-1", which should then be coerced to -1 or 1 as an integer, to be multiplied by the RHS of the equals. Nothing to fix here.

comment:3 Changed 11 years ago by Rick Waldron

@mikesherov nice, I forgot to close this after reviewig the code. Thanks!

Note: See TracTickets for help on using tickets.