Make Element#getStyle translate "inherit" and Element#visible work with display:inherit
Reported by John-David Dalton | June 24th, 2008 @ 06:03 PM | in 1.6.1
Garret Smith pointed out that Element#visible is a misleading name (that is true). He also pointed out that it doesnt use currentStyle or computedStyle so it missed display:inherit styles. This patch makes it use Element#getStyle which reads computed styles.
Comments and changes to this ticket
-
John-David Dalton June 24th, 2008 @ 06:04 PM
- → State changed from new to enhancement
-
-
John-David Dalton June 24th, 2008 @ 09:54 PM
- → State changed from enhancement to invalid
display may be set to "inherit" and thus the use of Element#getStyle is justified.
-
John-David Dalton June 24th, 2008 @ 09:54 PM
- → State changed from invalid to bug
-
John-David Dalton June 24th, 2008 @ 09:56 PM
- → Title changed from Make Element#visible use Element#getStyle so it can detect inherited values to Make Element#visible work with display:inherit
-
Tobie Langel June 26th, 2008 @ 06:32 PM
- → State changed from bug to invalid
- → Tag changed from to patched
This isn't possible for the reasons described here: http://tobielangel.com/2006/12/3...
-
John-David Dalton June 26th, 2008 @ 08:19 PM
- → Milestone changed from 1.6.0.3 to 1.6.1
- → State changed from invalid to bug
I don't think your reasons described in the article are relevant to this bug (I totally might have missed the reasons though).
I did test Element.getStyle and it returns "inherit" in Firefox.
SO this patch would require Element.getStyle to be fixed first.
<div id="pappa-bear" style="display:inline;"> <div id="baby-bear" style="display:inherit"> </div>var element = $('baby-bear'), value, style = 'display'; // currently IE ignores "inherit" and makes display "block", so this is more of a future proof IE check if (element.parentNode && element.getStyle('display') == 'inherit') value = element.currentStyle ? element.up().getStyle(style) : (document.defaultView.getComputedStyle(element, null) || {}).display; else value = element.getStyle(style); //works in Firefox, Opera, and Safari alert(value); //inline -
John-David Dalton June 26th, 2008 @ 08:29 PM
- → Title changed from Make Element#visible work with display:inherit to Make Element#getStyle translate "inherit" and Element#visible work with display:inherit
- → Tag cleared.
-
Juriy Zaytsev June 27th, 2008 @ 12:20 AM
What if we change #show to accept an optional "display value" parameter, and when not present, default to a current implementation?
element.show('inline'); // sets element's style.display to "inline" -
John-David Dalton June 27th, 2008 @ 02:17 AM
Juriy I am not sure if that is in the scope of this ticket.
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
