Bug Tracker

Modify

Ticket #7233 (closed bug: invalid)

Opened 4 years ago

Last modified 2 years ago

jQuery 1.4.3 changes behaviour of $('.e').css('width', null)

Reported by: kelvin@… Owned by: kelvin@…
Priority: low Milestone: 1.5
Component: css Version: 1.4.3
Keywords: css null Cc:
Blocking: Blocked by:

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...

Change History

comment:1 Changed 4 years ago by snover

  • Owner set to kelvin@…
  • Status changed from new to pending

Please provide a reduced test case.

comment:2 Changed 4 years ago by kelvin@…

  • Status changed from pending to 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

comment:3 Changed 4 years ago by jitter

@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

Last edited 4 years ago by jitter (previous) (diff)

comment:4 follow-up: ↓ 5 Changed 4 years ago by 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...

comment:5 in reply to: ↑ 4 Changed 4 years ago by Kelvin Luck <kelvin@…>

Replying to 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...

comment:6 Changed 4 years ago by addyosmani

  • Keywords css null added
  • Priority changed from undecided to low
  • Status changed from new to closed
  • Component changed from unfiled to css
  • Resolution set to invalid

As this issue has been resolved as a user error I am closing it as an invalid ticket for now.

comment:7 Changed 4 years ago by snover

#7240 is a duplicate of this ticket.

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.