Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
если мы договоримся, что скрытые элементы должны иметь класс hide, то все сведется к определению наличия этого класса у элемента или его родителей.
и влезали в загрузочный сектор дискетки
почему этот процесс становится причиной повторного вывода (laying out) элемента?

As stated earlier, the browser may cache several changes for you, and reflow only once when those changes have all been made. However, note that taking measurements of the element will force it to reflow, so that the measurements will be correct. The changes may or may not not be visibly repainted, but the reflow itself still has to happen behind the scenes.
This effect is created when measurements are taken using properties like offsetWidth, or using methods like getComputedStyle. Even if the numbers are not used, simply using either of these while the browser is still caching changes, will be enough to trigger the hidden reflow.
function test_offset()
{
var c=init();
var o = document.getElementsByTagName('meta').item(0);
profile('offsetHeight');
for(var i=0; i<1000; i++){
fnOffset(o);
c.appendChild(t.cloneNode(true));
}
profileEnd();
clean(c);
}
<div class='hide'>
<span id='test'>test</span>
</div>
<script type='text/javascript'>
alert(isHiddenFast(document.getElementById('test')));
</script>
В цитируемой статье явно указано, что вызов getComputedStyle также вызывает reflow, и причины отсутствия этого в IE и FF непонятны, хотя и радуют.
<body class='hide'>
<span id='test'>test</span>
</body>
body.hide .hide {
display:none;
}
<body class="hide">
<widget class="hide"></widget>
<p id="p1">test</p>
</body>
isHidden($('p1')); // ==true
function doesElementInheritCSSClass(el, cls)
{
var p=el;
var re=new RegExp('(^|\\s)'+cls+'($|\\s)');
while(p && !re.test(p.className))
p=p.parentNode;
return !!p;
}
offsetHeight или нечаянный спуск лавины reflow