Skip to main content

Bug Tracker

Side navigation

#9699 closed bug (fixed)

Opened June 29, 2011 02:58PM UTC

Closed August 25, 2011 07:34PM UTC

Last modified August 05, 2013 02:27PM UTC

removeAttr('style') does not consistently remove the style attribute in webkit

Reported by: azazel.private@gmail.com Owned by: timmywil
Priority: high Milestone: 1.6.3
Component: attributes Version: 1.6
Keywords: Cc:
Blocked by: Blocking:
Description

1. $('#item').css('visibility', 'hidden');

2. $('#item').removeAttr('style'); Element still hidden...

It works fine in jQuery < 1.6

Example: http:jsfiddle.net/azproduction/hhEka/

Attachments (0)
Change History (20)

Changed June 29, 2011 03:16PM UTC by timmywil comment:1

component: unfiledattributes
priority: undecidedlow
status: newopen

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.

Changed June 29, 2011 03:30PM UTC by timmywil comment:2

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', '')

Changed June 29, 2011 06:50PM UTC by timmywil comment:3

#9500 is a duplicate of this ticket.

Changed June 29, 2011 06:51PM UTC by timmywil comment:4

summary: In Chrome and Safari its impossible to show visibly hidden element via removeAttrremoveAttr('style') does not consistently remove the style attribute in webkit

Changed July 01, 2011 02:44PM UTC by anonymous comment:5

any workaround for removing all inline style ?

Shouldn't this work :

$("#item").prop("style", "")

?

(can't try now)

Changed July 01, 2011 02:53PM UTC by timmywil comment:6

_comment0: @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.1309532051305575
priority: lowhigh

@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.

Changed July 01, 2011 05:48PM UTC by anonymous comment:7

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.

Changed July 12, 2011 06:11PM UTC by rwaldron comment:8

resolution: → wontfix
status: openclosed

Changed August 25, 2011 03:58PM UTC by timmywil comment:9

milestone: 1.next1.6.3
resolution: wontfix
status: closedreopened

Changed August 25, 2011 03:58PM UTC by timmywil comment:10

owner: → timmywil
status: reopenedassigned

This should not have been closed.

Changed August 25, 2011 03:59PM UTC by timmywil comment:11

#10136 is a duplicate of this ticket.

Changed August 25, 2011 07:34PM UTC by timmywil comment:12

resolution: → fixed
status: assignedclosed

Revert back to always setting the attribute to empty string before removal. Fixes #9699.

Changeset: d723942b274e3e48dac82ebde11906a4cb349415

Changed April 18, 2012 08:04PM UTC by jQuery: eternally clueless comment:13

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.

Changed April 18, 2012 08:13PM UTC by dmethvin comment:14

Welcome David Mark, and thanks!

Changed May 22, 2012 12:07AM UTC by iamchriswick comment:15

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?

Changed October 16, 2012 07:55AM UTC by GU Yiling comment:16

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!

Changed February 23, 2013 05:50PM UTC by anonymous comment:17

https://bugs.webkit.org/show_bug.cgi?id=99295 was fixed on 2012-11-06. Can this hack be removed?

Changed February 24, 2013 09:46PM UTC by mikesherov comment:18

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.

Changed February 24, 2013 09:48PM UTC by mikesherov comment:19

New ticket created for future hack removal: #13511

Changed August 05, 2013 02:27PM UTC by ist.kein.problem@googlemail.com comment:20

Just that helped for me.

$('#item').attr({ 'style' : '' });