Bug Tracker

Modify

Ticket #10617 (closed bug: worksforme)

Opened 20 months ago

Last modified 18 months ago

Type coersion wrongly placed

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

Description

Please take a look at this line of code:

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

specifically

+( 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

comment:1 Changed 20 months ago by rwaldron

  • Owner set to rwaldron
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to css
  • Milestone changed from None to 1.next

Good catch. Patch to follow

comment:2 Changed 18 months ago by mikesherov

  • Status changed from assigned to closed
  • Resolution set to worksforme

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 18 months ago by rwaldron

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.