5 ms·
Abstractions are meant to, well, abstract an implementation. You might very well want to abstract a native operation for a bunch of different reasons. You don't
by jpatte 13y ago
Abstractions are meant to, well, abstract an implementation. You might very well want to abstract a native operation for a bunch of different reasons. You don't need to, but maybe you should.
For example,
$(el).hide()
is quite more readable than
el.style.display = 'none'
. And I'm not even talking about the other advantages.
- daleharvey 13y agoIts el.hidden = true; in modern browsers
- nostrademons 13y agoI'm curious - is this spec'd anywhere? I just tried it in Chrome and it works great, but I couldn't find it in any of the specs for Element or Node.
- epmatsw 13y agoThe best I found http://www.whatwg.org/specs/web-apps/current-work/multipage/editing.html#the-hidden-attribute http://www.whatwg.org/specs/web-apps/current-work/multipage/... https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#hidden https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...
- rwaldron 13y agoThe documented semantics of the hidden attribute say otherwise https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes#hidden https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att... http://www.w3.org/html/wg/drafts/html/master/editing.html#the-hidden-attribute http://www.w3.org/html/wg/drafts/html/master/editing.html#th... " it is incorrect to use hidden to hide panels in a tabbed dialog, because the tabbed interface is merely a kind of overflow presentation — one could equally well just show all the form controls in one big page with a scrollbar"
- talmand 13y agoAccording to specs mentioned elsewhere, it seems to have reasons to exist other than just display hide/show purposes. It's easily overridden by CSS. el.style.display = 'none' pretty much works everywhere. To me, it seems to depend upon what the purpose of hiding/showing the element is in specific cases.
- drdaeman 13y ago> $(el).hide() > el.style.display = 'none' You meant something more like document.querySelectorAll(el).forEach(function(e) { e.style.display = 'none'; } and a polyfill for IE8 due to lack of native Array#forEach, right?