Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11604 closed feature (fixed)

Switch $(elem).width(-val) from no-op to $(elem).width(0)

Reported by: dmethvin Owned by:
Priority: low Milestone: 1.8
Component: dimensions Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


The fix in #1599 changed .width(-val) to be a no-op because it throws an error in IE. Later that same lifetime, we decided to make negative values equal 0 for animations in #10294 and #11415.

To simplify things and make them more consistent, it would be nice to have .css() limit any values to 0 that can't go negative, so it doesn't have to be handled different ways in two places.

This is a change in behavior and something with a unit test in dimensions, but since negative values are actually outside the range of valid inputs I think it's within our rights to change this. Our main goal was to avoid an error in IE (for example in animations that undershoot), and the proposed change still does that.

Change History (7)

comment:1 Changed 11 years ago by dmethvin

Component: unfileddimensions
Milestone: None1.8
Priority: undecidedlow
Status: newopen

comment:2 Changed 11 years ago by gnarf


comment:3 Changed 11 years ago by gnarf

Just to mention - the natural behavior of elem.style.width = "-1px" is that elem.style.width remains unchanged. http://cl.ly/2J230E0y1j2O0D3u1R1t -- more thoughts?

comment:4 Changed 11 years ago by gnarf

My personal opinion is that the intent of someone setting one of these values to a negative number is to set it UNDER zero. The closest we can get them to that intent is to set it to zero

comment:5 Changed 11 years ago by mikesherov

I'm fine either way, but either way, animate should have the same behavior.

My personal pref is set to 0.

comment:6 Changed 11 years ago by dmethvin

Just to be sure, let's set it to -0. :)

When we do the release notes I'll be sure to point this out as a behavioral change, but code should not be depending on (INVALID) negative values being a no-op.

comment:7 Changed 11 years ago by dmethvin

Resolution: fixed
Status: openclosed

Fixed in 1.8pre.

Note: See TracTickets for help on using tickets.