-
-
Save joneff/414384 to your computer and use it in GitHub Desktop.
details:not([open]) > :not(summary) {display: none;} |
And so is :not ;)
If I was worrying about IE6 not being able to display this snippet, I wouldn't have written in the first place. Sometimes (especially when possible) one should really take advantage of technology regardless the legacy players out there.
If I was worrying about IE6 not being able to display this snippet, I wouldn't have written in the first place.
Sure — please don’t get me wrong, I’m just pointing it out so less experienced developers don’t get bitten by the lack of browser support. If you only need to support modern browsers (and you don’t need to account for every possible edge case), this is a lovely lightweight snippet!
Also it won’t take care of the edge case where direct child text nodes are part of the
(as the CSS rule details:not([open]) > :not(summary) {display: none;} won’t target those).
Point taken
Btw, the code in the separate .js
seems to differ from the JavaScript in the HTML. Just a heads up.
For future reference, this fallback is only targeted at modern browsers.
.querySelectorAll
and.hasAttribute
are only supported in IE8+.addEventListener
works in IE9+.Also it won’t take care of the edge case where direct child text nodes are part of the
<summary>
(as the CSS ruledetails:not([open]) > :not(summary) {display: none;}
won’t target those).If you ever need a more robust (but slightly heavier) solution, feel free to use http://mathiasbynens.be/notes/html5-details-jquery :)