Skip to main content

Bug Tracker

Side navigation

#7080 closed bug (duplicate)

Opened September 25, 2010 01:04AM UTC

Closed October 06, 2010 01:30AM UTC

Last modified March 15, 2012 01:34PM UTC

css function should check for NaN

Reported by: davidalism Owned by:
Priority: high Milestone: 1.4.3
Component: css Version: 1.4.2
Keywords: NaN, error, invalud argument, css Cc:
Blocked by: Blocking:
Description

4564 jQuery.fn.css = function( name, value ) {

4565 return access( this, name, value, true, function( elem, name, value ) {

4566 if ( value === undefined ) {

4567 return jQuery.curCSS( elem, name );

4568 }

4569

4570 if ( typeof value === "number" && !rexclude.test(name) ) {

4571 value += "px";

4572 }

4573

4574 jQuery.style( elem, name, value );

4575 });

4576 };

if value is NaN, typeof value === "number" && !rexclude.test(name) returns true, and so "NaNpx" will be passed to jQuery.style, which causes error.

This occur frequently, because we cannot guarantee value is never NaN. One example is: ele.css('right',parseInt(anotherEle.css('right')))

where anotherEle.css('right') is 'auto'

IMO, isNaN(value) should be added.

Attachments (0)
Change History (1)

Changed October 06, 2010 01:30AM UTC by snover comment:1

resolution: → duplicate
status: newclosed

Duplicate of #6848.