#1438 closed bug (fixed)
Note to IE opacity filter
Reported by: | hobbit | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.2 |
Component: | effects | Version: | 1.1.3 |
Keywords: | IE, filter | Cc: | |
Blocked by: | Blocking: |
Description
The original code in the .attr method: return elem.filter ?
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString():"";
If we defined a filter to the animated element, but don't modifie the opacity under jQuery amination, then the match will return null. This problem like http://dev.jquery.com/ticket/1101#comment:5, but we can't use this expression.
(parseFloat( (elem.filter.match(/opacity=([^)]*)/) || [])[1] )/100).toString();
This returns a "NaN" string. We should use this:
return elem.filter && /opacity=/.test(elem.filter)? (elem.filter.match(/opacity=(\d*)/)[1] / 100).toString() : "";
Now the division always returns a number, then we don't call the parseFloat function. Here you are the corrected code:
if ( jQuery.browser.msie && name == "opacity" ) { if ( value != undefined ) { // IE has trouble with opacity if it does not have layout // Force it by setting the zoom level elem.zoom = 1; // Set the alpha filter to set the opacity elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/, "") + (isNaN(parseFloat(value)) ? "" : "alpha(opacity=" + value * 100 + ")"); } return elem.filter && /opacity=/.test(elem.filter)? (elem.filter.match(/opacity=(\d*)/)[1] / 100).toString() : ""; }
And there are two .match callings in the curCSS method, but the .test is faster like .match to checking.
if (prop.match(/float/i)) if (/float/i.test(prop))
Change History (1)
comment:1 Changed 15 years ago by
Milestone: | 1.1.4 → 1.2.2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
Fixed in [4013]. There are various other changes the author proposed but didn't spell out why or what they fixed so those changes were not made. For example the description changes the current RegExp from
to
without saying why. It seems to me that would fail on a floating point number but I didn't test it. If the other changes made outside the JS null error are there for good reasons please reopen this ticket (or open a new one) with those details.