MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/psta9x/my_friend_hiding_a_card_in_javascript/hdsg6iv/
r/badcode • u/Hardway_ • Sep 21 '21
20 comments sorted by
View all comments
Show parent comment
16
I'm saying that they shouldn't set hidden to be false because it's bad style; they should remove the attribute entirely (https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute). Unless you need to support IE, classList is fine (https://developer.mozilla.org/en-US/docs/Web/API/Element/classList).
I mistakenly said that setting hidden to false won't work on every browser. I could have sworn I saw that in action at some point, but I'm not finding any resource that backs up my claim
11 u/keethraxmn Sep 22 '21 There are oddities in hiding stuff in IE (old versions at least) but I think it's display:none that's the issue. Too lazy to look it back up. 3 u/cmd-t Sep 22 '21 It’s not bad style. It’s even in the spec: https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute 4 u/[deleted] Sep 22 '21 I guess I'm wrong about that then. Learn something new every day
11
There are oddities in hiding stuff in IE (old versions at least) but I think it's display:none that's the issue. Too lazy to look it back up.
3
It’s not bad style. It’s even in the spec: https://html.spec.whatwg.org/multipage/interaction.html#the-hidden-attribute
4 u/[deleted] Sep 22 '21 I guess I'm wrong about that then. Learn something new every day
4
I guess I'm wrong about that then. Learn something new every day
View all comments
Show parent comment
16
u/[deleted] Sep 22 '21
I'm saying that they shouldn't set hidden to be false because it's bad style; they should remove the attribute entirely (https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute). Unless you need to support IE, classList is fine (https://developer.mozilla.org/en-US/docs/Web/API/Element/classList).
I mistakenly said that setting hidden to false won't work on every browser. I could have sworn I saw that in action at some point, but I'm not finding any resource that backs up my claim