Side navigation
#7233 closed bug (invalid)
Opened October 18, 2010 08:50AM UTC
Closed October 18, 2010 02:02PM UTC
Last modified March 13, 2012 09:17PM UTC
jQuery 1.4.3 changes behaviour of $('.e').css('width', null)
Reported by: | kelvin@kelvinluck.com | Owned by: | kelvin@kelvinluck.com |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | css | Version: | 1.4.3 |
Keywords: | css null | Cc: | |
Blocked by: | Blocking: |
Description
My jScrollPane plugin [ http://jscrollpane.kelvinluck.com/ ] breaks when I update to jQuery 1.4.3. I haven't gone over it fully yet but I suspect that this line is no longer working as it did:
elem.css('width', null);
The aim of this line is to remove any styles added by jQuery which were effecting the width of the element so that it can take up it's natural space in the page. It is used so that you can reinitialise the plugin after the size of elements on the page has changed (e.g. http://jscrollpane.kelvinluck.com/dynamic_width.html ).
You can experiment here:
http://www.jsfiddle.net/VKYHK/
Try resizing your browser window. The scrollbars will update correctly. Now change it to jQuery 1.4.3 on the left hand side and re-run the page. When you resize you will see that the scroll pane doesn't correctly calculate its new width...
Attachments (0)
Change History (7)
Changed October 18, 2010 09:08AM UTC by comment:1
owner: | → kelvin@kelvinluck.com |
---|---|
status: | new → pending |
Changed October 18, 2010 09:24AM UTC by comment:2
status: | pending → new |
---|
I will as soon as I get a spare few minutes... As mentioned, I suspect the cause is that
.css('width', null)(in the block starting on line 129 of http://jscrollpane.kelvinluck.com/script/jquery.jscrollpane.js ) is now behaving differently in 1.4.3
Changed October 18, 2010 10:18AM UTC by comment:3
_comment0: | @kelvin \ You are right `.css( 'width', null )` in the plugins code is the culprit. \ \ Using `null` as value is just wrong. The correct way to remove a style is `css( 'width', '')`. \ \ Calling `css( key, null )` in jQuery < 1.4.3 just seemed to work but actually did the wrong thing by setting the value to `nullpx` which throws errors in IE. \ \ This behavior was fixed in 1.4.3 see #7116 \ \ So you should report this invalid use of `css( key, null )` to the plugins author and request that he fixes it in his code. \ → 1287397163078914 |
---|---|
_comment1: | @kelvin \ You are right `.css( 'width', null )` in the plugins code is the culprit. \ \ Using `null` as value is just wrong. The correct way to remove a style is `css( 'width', '')`. \ \ Calling `css( key, null )` in jQuery < 1.4.3 just seemed to work but actually did the wrong thing by setting the value to `nullpx` which throws errors in IE. \ \ This behavior was fixed in 1.4.3 see #7116 \ \ So you should report this invalid use of `css( key, null )` to the plugins author and request that he fixes it in his code. \ \ P.S.: Condensed [http://www.jsfiddle.net/WuW9L/ live test case] \ → 1287397229194520 |
@kelvin
You are right .css( 'width', null )
in the plugins code is the culprit.
Using null
as value is just wrong. The correct way to remove a style is css( 'width', '')
.
Calling css( key, null )
in jQuery < 1.4.3 just seemed to work but actually did the wrong thing by setting the value to nullpx
which throws errors in IE.
This behavior was fixed in 1.4.3 see #7116
So you should report this invalid use of css( key, null )
to the plugins author and request that he fixes it in his code.
P.S.: Condensed live test case
Changed October 18, 2010 01:28PM UTC by comment:4
@jitter thanks for the clarification and the condensed test case!
I am the author of the plugin and have fixed the code. I thought that I ran into a difference between setting css(key, '') and css(key, null) while I was developing the plugin (and that null worked while '' didn't). However, I've just tested and the empty string seems to work great.
Thanks again for the help,
Kelvin :)
p.s. This ticket can be closed as a user error. I don't seem to have permission to do it...
Changed October 18, 2010 01:30PM UTC by comment:5
Replying to [comment:4 Kelvin Luck <kelvin@…>]:
@jitter thanks for the clarification and the condensed test case! I am the author of the plugin and have fixed the code. I thought that I ran into a difference between setting css(key, "") and css(key, null) while I was developing the plugin (and that null worked while "" didn't). However, I've just tested and the empty string seems to work great. Thanks again for the help, Kelvin :) p.s. This ticket can be closed as a user error. I don't seem to have permission to do it...
Sorry for the messed up formatting - it appears that two single quotes next to each other mean something in Trac. In the quote above I've turned them into double quotes...
Changed October 18, 2010 02:02PM UTC by comment:6
component: | unfiled → css |
---|---|
keywords: | → css null |
priority: | undecided → low |
resolution: | → invalid |
status: | new → closed |
As this issue has been resolved as a user error I am closing it as an invalid ticket for now.
Please provide a reduced test case.