Ticket #1239 (closed bug: fixed)
hide function broken in Safari on elements not in DOM (see example)
| Reported by: | remysharp | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.3 |
| Component: | effects | Version: | 1.2.6 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
var p = $('<p>test</p>').hide();
alert(p[0].style.display);
In Firefox, correctly displays 'none', in Safari this is blank. The effect is when preparing a new element to fade in to the page the fade doesn't work in Safari (because it's already fully visible).
Tested with jQuery 1.1.3a, Firefox 2 and Safari 2 on OS 10.4 and IE7.
Work around:
var p = $('<p>test</p>').css('display', 'none');
alert(p[0].style.display);
Attachments
Change History
comment:1 Changed 6 years ago by davidserduke
- Owner set to davidserduke
- Status changed from new to assigned
comment:2 Changed 6 years ago by davidserduke
- Owner davidserduke deleted
- Status changed from assigned to new
comment:3 Changed 5 years ago by flesler
- Milestone changed from 1.1.3 to 1.2.4
Could you retest this with jQuery 1.2.4 ?
comment:4 Changed 5 years ago by remysharp
Test failed. I've attached a test to this ticket, but also uploaded it here:
http://remysharp.com/demo/safari-display-bug.html
I did propose a fix for it a little while ago, but the change was deep inside the core jQuery library and I wasn't confident enough to make the change without a second opinion:
http://groups.google.com/group/jquery-dev/browse_thread/thread/9695ea22968d98b3/ef45b65f3ceb2e81
Changed 5 years ago by remysharp
-
attachment
safari-display-bug.html
added
Demo of Safari display prop bug. Result should say: 'none'
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

This problem here is that jQuery reports the newly created element as :hidden so when hide() is called it essentially just returns. There is quite a bit of code in curCSS() (which :hidden uses) that is special cased to Safari in an attempt to handle how it returns its current CSS, but apparently this is one case where it fails.
There is an easy work around for this bug as stated above. I'm going to leave it open for now but personally I think the risks at this point of fixing this minor bug outweigh the gain of fixing it.