Side navigation
#4420 closed bug (invalid)
Opened March 25, 2009 03:44PM UTC
Closed June 12, 2010 02:02PM UTC
Last modified March 14, 2012 02:23PM UTC
Internet Explorer 7 error: problem setting elem[ name ] = value
Reported by: | erinnn | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | attributes | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I found a minor problem in IE that does not happen with Firefox or Chrome.
On line 1002 and 1065 of jQuery JavaScript Library v1.3.2
"elem[ name ] = value;"
will throw an error, if the value can not be set on the property.
In my case, I found the error when I tried to assign NaN px from a calculation to the left property of an element.
FIrefox and chrome continued, while IE my element did not display.
Putting this line in a try block with an empty catch allowed IE to fail more gracefully, like Chrome and Firefox did when given a bad value.
Attachments (0)
Change History (6)
Changed March 26, 2009 02:10AM UTC by comment:1
Changed March 26, 2009 01:38PM UTC by comment:2
What I meant to highlight as the issue was inconsistent behavior in IE.
The NaN was just a bad input - when this code fails to set the value on a property the behavior in IE is inconsistent with (and worse than) what other browsers show. Making behavior more predictable across browsers is one of the highlights of jQuery.
The two other browsers failed gracefully, masking the underlying error. Doing so with the library in IE would help standardize javascript behavior across browsers in failure conditions.
Changed April 22, 2009 09:32AM UTC by comment:3
Changing
elem[ name ] = value
to
try{elem[ name ] = value} catch(err){};
on lines 1002 and 1065
not only gives consistent behavior, but allows the script to continue. IE7 halts under some conditions.
Changed August 07, 2009 05:01PM UTC by comment:4
The conditions where IE halts are ones where Firefox is ignoring code errors AFAICT. You'd want to figure out why you were passing
NaNto jQuery.
Changed September 21, 2009 04:47PM UTC by comment:5
I had the same problem, and on IE8 too. So I solved using this way at line 1060 of jquery-1.3.2.js:
on:
if ( set ) elem[ name ] = value;
to:
if ( set ) { if ((value == 'NaNpx')||(value == 'px')) value = ''; elem[ name ] = value; }
Now it's working like a charm.
Changed June 12, 2010 02:02PM UTC by comment:6
component: | unfiled → attributes |
---|---|
resolution: | → invalid |
status: | new → closed |
Closing the ticket, no test case showing a bug. The string "NaN" for .attr or .css is not valid input, so code should not be passing this to jQuery.
It sounds like this would just mask the underlying error though. Where was the
} coming from?