Ticket #4854: visible.diff
| File visible.diff, 2.2 kB (added by Tobie, 3 years ago) |
|---|
-
test/unit/dom.html
old new 17 17 #not_floating_style { float: none } 18 18 #floating_style { float: left } 19 19 #op2 { opacity:0.5;filter:alpha(opacity=50)progid:DXImageTransform.Microsoft.Blur(strength=10);} 20 #hidden_element {display: none;} 20 21 21 22 /* ]]> */ 22 23 </style> … … 30 31 <!-- Log output --> 31 32 <div id="testlog"> </div> 32 33 34 <span id="visible_element"> 35 visible 36 </span> 37 <div id="hidden_element_inline_style" style="display: none;"> 38 hidden 39 </div> 40 <div id="hidden_element"> 41 hidden 42 <div id="child_of_a_hidden_element"> 43 parent hidden 44 <div id="grandchild_of_a_hidden_element"> 45 grandparent hidden 46 </div> 47 </div> 48 </div> 49 33 50 <div> 34 51 <table> 35 52 <tbody id="table"> … … 153 170 assertIdentical(elt, $(elt)); 154 171 assertRespondsTo('hide', elt); 155 172 }}, 173 174 testVisible: function() {with(this) { 175 assert($('visible_element').visible()); 176 assert(!$('hidden_element_inline_style').visible()); 177 assert(!$('hidden_element').visible()); 178 assert(!$('child_of_a_hidden_element').visible()); 179 assert(!$('grandchild_of_a_hidden_element').visible()); 180 benchmark(function(){ 181 $('visible_element').visible(); 182 },1000); 183 benchmark(function(){ 184 $('visible_element').style.display != 'none'; 185 },1000); 186 }}, 156 187 157 188 testGetElementsByClassName: function() {with(this) { 158 189 assertElementsMatch(document.getElementsByClassName('A'), 'p.A', 'ul#class_names_ul.A', 'li.A.C'); -
src/dom.js
old new 75 75 76 76 Element.Methods = { 77 77 visible: function(element) { 78 return $(element).style.display != 'none'; 78 element = $(element); 79 var style = element.getStyle('display'); 80 if(style == 'none' || style == null) return false; 81 if(element.ancestors().any(function(ancestor) { 82 return ancestor.getStyle('display') == 'none'; 83 })) return false; 84 return true; 79 85 }, 80 86 81 87 toggle: function(element) {