Skip to main content

Bug Tracker

Side navigation

#11604 closed feature (fixed)

Opened April 18, 2012 11:31PM UTC

Closed May 18, 2012 02:05AM UTC

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:
Description

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.

Attachments (0)
Change History (7)

Changed April 18, 2012 11:32PM UTC by dmethvin comment:1

component: unfileddimensions
milestone: None1.8
priority: undecidedlow
status: newopen
version: 1.7.11.7.2

Changed April 20, 2012 01:35AM UTC by gnarf comment:2

+1

Changed April 27, 2012 03:35AM UTC by gnarf comment:3

Just to mention - the natural behavior of

 elem.style.width = "-1px" 
is that
 elem.style.width 
remains unchanged. http://cl.ly/2J230E0y1j2O0D3u1R1t -- more thoughts?

Changed April 27, 2012 03:39AM UTC by gnarf comment:4

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

Changed April 27, 2012 03:52AM UTC by mikesherov comment:5

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

My personal pref is set to 0.

Changed April 28, 2012 03:49PM UTC by dmethvin comment:6

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.

Changed May 18, 2012 02:05AM UTC by dmethvin comment:7

resolution: → fixed
status: openclosed

Fixed in 1.8pre.