Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#7080 closed bug (duplicate)

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.

Change History (1)

comment:1 Changed 9 years ago by snover

Resolution: duplicate
Status: newclosed

Duplicate of #6848.

Note: See TracTickets for help on using tickets.