I was looking at the document.hidden specs here to understand what exactly hidden entails:
- If steps to determine the visibility state return
visible, then returnfalse. 2. Otherwise, returntrue.
Note
Support for
hiddenattribute is maintained for historical reasons. Developers should usevisibilityStatewhere possible.
visibilityState is another property that can return one of three strings: 'visible', 'hidden', or 'prerender'.
document.hidden (as indicated by the above rules) returns true for 'visible' and false for all other strings.
I am curious about the note. Why do they say that developers should prefer visibilityState to hidden?
Is it simply because visibilityState gives you more "power" (re: granularity) in that it's more specific about what state the document is in, whereas hidden dumbs it down by turning the four states into two states, "hidden" or "not hidden"?
I understand that this may only be answerable by the people who wrote the specs, but maybe they're crawling around here.
A preemptive note: I'm going to guess that this may be closed as "opinion-based", because it'll attract opinionated answers, and while it certainly may attract answers like that, this can be answered objectively by those who wrote the specs, so I'll take my chances.
The notice of hidden being maintained for historical reasons has been removed in this PR.
There is some discussion here about this change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With