#9699 closed bug (fixed)
removeAttr('style') does not consistently remove the style attribute in webkit
Reported by: | Owned by: | Timmy Willison | |
---|---|---|---|
Priority: | high | Milestone: | 1.6.3 |
Component: | attributes | Version: | 1.6 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
- $('#item').css('visibility', 'hidden');
- $('#item').removeAttr('style'); Element still hidden...
It works fine in jQuery < 1.6
Change History (20)
comment:1 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:2 Changed 12 years ago by
This seems to be a webkit bug. removeAttribute does not consistently remove the style attribute at all times.
@azazel In the meantime, the recommended way to reset a style is to set it to empty string with css:
$('#item').css('visibility', '')
comment:4 Changed 12 years ago by
Summary: | In Chrome and Safari its impossible to show visibly hidden element via removeAttr → removeAttr('style') does not consistently remove the style attribute in webkit |
---|
comment:5 Changed 12 years ago by
any workaround for removing all inline style ?
Shouldn't this work :
$("#item").prop("style", "")
?
(can't try now)
comment:6 Changed 12 years ago by
Priority: | low → high |
---|
@anonymous: that would be bad. The style property is an object which contains all styles, including defaults, for the element. You could do
.attr('style', '');
or
elem.style.cssText = '';
or set each style individually with the css method as shown above.
comment:7 Changed 12 years ago by
I found that
.attr('style', '')
works good.
You're right, I forgot about the cssText subproperty... Maybe it would be more reliable/cross-browser if we used this.
comment:8 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | open → closed |
comment:9 Changed 12 years ago by
Milestone: | 1.next → 1.6.3 |
---|---|
Resolution: | wontfix |
Status: | closed → reopened |
comment:10 Changed 12 years ago by
Owner: | set to Timmy Willison |
---|---|
Status: | reopened → assigned |
This should not have been closed.
comment:12 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Revert back to always setting the attribute to empty string before removal. Fixes #9699.
Changeset: d723942b274e3e48dac82ebde11906a4cb349415
comment:13 Changed 11 years ago by
Do you idiots not get it? The style
attribute is never being set. The visibility
property of the style
object is being set. Of course removeAttribute
does nothing. The only reason this worked before was because of your broken attr
implementation that mucked with properties.
comment:15 Changed 11 years ago by
Hi,
I have a
<span style="display: none; ">
that is generated in my code, and I cant figure out why "display: none;" is set.
I have tried using:
$('span').removeAttr('style');
and
$('span').attr('style', '')
...but none of them are working.
Some how
$('span').removeAttr(style);
is working, but of cource that give an error due to the missing around style.
Any suggestions?
comment:16 Changed 11 years ago by
Hi guys,
Here's a good news: WebKit might fix the related bug (https://bugs.webkit.org/show_bug.cgi?id=99295) soon and jQuery can get rid of the current hack in the near future!
comment:17 Changed 11 years ago by
https://bugs.webkit.org/show_bug.cgi?id=99295 was fixed on 2012-11-06. Can this hack be removed?
comment:18 Changed 11 years ago by
At some point in the future, yes, we can remove the hack. Unfortunately, there's still a lot of old version of webkit floating around out there who don't have this fix yet.
The style attribute is not always getting removed, but this is strangely inconsistent. It does work sometimes and it does work when done from the console.