Ticket #6841 (closed bug: worksforme)
IE<9 stylesheets with filter rules break when setting opacity
| Reported by: | jdlrobson | Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 1.next |
| Component: | css | Version: | 1.4.3 |
| Keywords: | filter ie6 ie7 show hide | Cc: | |
| Blocking: | #6652 | Blocked by: |
Description
In Internet Explorer the css filter property is used for opacity whenever you run .show / .hide functions
The style attribute of the #test element is edited during the transition to alter opacity and when the animation finishes filter is set as empty string on the elements style attribute.
Thus any existing css rules using 'filter' are cancelled out which I believe is incorrect behaviour.
As a solution I think either
At the end of the transition the filter rule in the style of #test should be removed so the css rule gets the power back. (Try clicking magic button to demonstrate). OR Opacity should not be applied for elements which already have the filter css rule.
See http://jonrobson.me.uk/static/mtc/jquerybug.html for a demo of the problem.
Change History
comment:1 follow-up: ↓ 5 Changed 3 years ago by snover
- Status changed from new to open
- Summary changed from IE6/7 css using filter rule wiped out by use of show() and hide() functions to IE6/7 stylesheets with filter rules break when setting opacity
- Priority set to high
- Version changed from 1.4.2 to 1.4.3
- Milestone 1.4.3 deleted
- Keywords show hide added
comment:3 in reply to: ↑ description Changed 3 years ago by tommy
Replying to jdlrobson:
As a solution I think either
At the end of the transition the filter rule in the style of #test should be removed so the css rule gets the power back. (Try clicking magic button to demonstrate).
That's not a good idea. All the filters should be kept during transition.
OR Opacity should not be applied for elements which already have the filter css rule.
That's even worse idea, because I'd make impossible to fade out elements with shadow (for instance).
IMHO setting opacity in IE should be rewritten and currentStyle.filter instead of style.filter should be taken into account.
comment:4 Changed 3 years ago by jdlrobson@…
I suggested those 2 solutions as I didn't think filters could be combined (never tried myself). Obviously if multiple filters can be used yes that should definitely happen.
comment:5 in reply to: ↑ 1 Changed 3 years ago by tommy
Replying to snover:
So, I guess we need to make sure we copy over filters from currentStyle when messing with opacity in IE<9?
Yes.
comment:6 Changed 3 years ago by tommy
My suggestion is to replace following code (starting from line 5269 in jquery-1.4.4rc2.js):
// Set the alpha filter to set the opacity var opacity = jQuery.isNaN(value) ? "" : "alpha(opacity=" + value * 100 + ")", filter = style.filter || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : style.filter + ' ' + opacity;
with:
// Set the alpha filter to set the opacity var opacity = jQuery.isNaN(value) ? "alpha(opacity=100)" : "alpha(opacity=" + value * 100 + ")", filter = elem.currentStyle.filter || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : filter + ' ' + opacity;
comment:10 Changed 2 years ago by snover
#8273 is a duplicate of this ticket.
comment:11 Changed 2 years ago by Alex Yaroshevich <qfox@…>
see also: http://jsfiddle.net/AWjgs/10/
comment:13 Changed 16 months ago by mikesherov
- Summary changed from IE6/7 stylesheets with filter rules break when setting opacity to IE<9 stylesheets with filter rules break when setting opacity
comment:14 Changed 13 months ago by mikesherov
- Status changed from open to closed
- Resolution set to worksforme
This works in 1.7.2:
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

test case
So, I guess we need to make sure we copy over filters from currentStyle when messing with opacity in IE<9?