Skip to main content

Bug Tracker

Side navigation

#4358 closed bug (invalid)

Opened March 16, 2009 12:21PM UTC

Closed October 14, 2009 03:27AM UTC

Last modified March 14, 2012 02:33PM UTC

curCSS function in IE: "invalid argument"

Reported by: sdyson Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

The "curCSS" function has a special case for IE that uses "element.currentStyle". It sets a value on "style.left" and then retrieves the value as a way to convert to pixels. This works well most of the time but blows up for fields with multiple values. For example it is valid for "padding" to have a value of "0px 2px". In such a case you get an "invalid argument" error on line 835: "style.left = ret || 0;"

This block of code seems to have originated from a fix by Dean Edwards at:

http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291

Attachments (1)
  • curCSSTestCase.zip (37.5 KB) - added by carmine March 16, 2009 05:23PM UTC.

    Test case showing the bug under IE7

Change History (9)

Changed March 16, 2009 04:22PM UTC by carmine comment:1

I have the same issue with a margin.

It seems that replacing all the

.left
in the function with
[name]
fixes the bug.

I'll try to build a test case.

Changed March 16, 2009 05:34PM UTC by carmine comment:2

I just added a use case to the ticket. It can also be seen at http://www.novactive.com/2009-03-curcss/index.htm.

Please note that I use the selecteSizer plugin to trigger the bug.

I also added a patch in the page.

Changed March 17, 2009 12:43PM UTC by sdyson comment:3

Thanks for the test case.

I'm not sure if your fix is correct according to the intention of the function. As I understand it the function will return a given css property but any non-px dimensions will get converted to px. Your function still uses pixelLeft for the return value so if I ask for "padding" which has an original value of "0px 2px" your function will return me "2px".

I think what might be needed is to split multi-value properties into the individual values, convert each in turn and then concatenate them together.

Changed March 17, 2009 12:53PM UTC by sdyson comment:4

Actually, since padding is not related to left we don't know what pixelLeft will return.

Changed March 17, 2009 03:47PM UTC by carmine comment:5

Yes, I just managed to prevent the error for IEs.

I thought that the error came from the use of

.left
that should be already defined for
style.left
, I did not get further (lack of time and knowledge).

Changed March 17, 2009 04:03PM UTC by sdyson comment:6

The error happens because left expects a single dimension (e.g. 2px, 2%, 2em etc) but if the requested property is a multi-value one such as padding then the left property will fail to parse it.

Your solution is likely to have some very strange side-effects because you are returning a completely different property to the one that was originally asked.

Changed March 17, 2009 05:37PM UTC by carmine comment:7

Oh, I did not understand that the code was only intending to get the left value... I do not understand why this value is so much more important than others...

Changed March 17, 2009 05:51PM UTC by sdyson comment:8

The left property is being used because it has a corresponding pixelLeft property allowing conversion to pixels. The original left value is set back afterwards.

I may have some time tomorrow to have a go at fixing this.

Changed October 14, 2009 03:27AM UTC by dmethvin comment:9

resolution: → invalid
status: newclosed

The documentation for

.css()
is clear that shorthand properties are not supported for setting. The test case uses minified code so it's not very helpful for debugging. It appears that these bugs are in the plugins that cause the issue, not in jQuery, so please report them to the plugin authors.