File tree Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Expand file tree Collapse file tree 4 files changed +37
-3
lines changed Original file line number Diff line number Diff line change 232
232
* // -> false
233
233
**/
234
234
function visible ( element ) {
235
- return $ ( element ) . getStyle ( 'display' ) !== 'none' ;
235
+ return Element . getStyle ( element , 'display' ) !== 'none' ;
236
236
}
237
237
238
238
/**
2647
2647
function getStyle ( element , style ) {
2648
2648
element = $ ( element ) ;
2649
2649
style = normalizeStyleName ( style ) ;
2650
+ var doc = element . ownerDocument ;
2650
2651
2651
2652
// Try inline styles first.
2652
2653
var value = element . style [ style ] ;
2653
2654
if ( ! value || value === 'auto' ) {
2654
2655
// Reluctantly retrieve the computed style.
2655
- var css = document . defaultView . getComputedStyle ( element , null ) ;
2656
+ var css = doc . defaultView . getComputedStyle ( element , null ) ;
2656
2657
value = css ? css [ style ] : null ;
2657
2658
}
2658
2659
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+ < head >
4
+ < style type ="text/css " media ="screen ">
5
+ .h { display : none; }
6
+ </ style >
7
+ </ head >
8
+ < body >
9
+ < p > visible</ p >
10
+ < p class ="h "> hidden</ p >
11
+ </ body >
12
+ </ html >
Original file line number Diff line number Diff line change @@ -338,11 +338,20 @@ suite('DOM', function () {
338
338
assert . equal ( element . up ( ) , wrapper ) ;
339
339
} ) ;
340
340
341
- test ( '#visible' , function ( ) {
341
+ test ( '#visible' , function ( done ) {
342
342
assert . notEqual ( 'none' , $ ( 'test-visible' ) . style . display ) ;
343
343
assert ( $ ( 'test-visible' ) . visible ( ) ) ;
344
344
assert . equal ( 'none' , $ ( 'test-hidden' ) . style . display ) ;
345
345
assert ( ! $ ( 'test-hidden' ) . visible ( ) ) ;
346
+ assert ( ! $ ( 'test-hidden-by-stylesheet' ) . visible ( ) ) ;
347
+ var iframe = $ ( 'iframe' ) ;
348
+ // Wait to make sure the IFRAME has loaded.
349
+ setTimeout ( function ( ) {
350
+ var paragraphs = iframe . contentWindow . document . querySelectorAll ( 'p' ) ;
351
+ assert ( Element . visible ( paragraphs [ 0 ] ) ) ;
352
+ assert ( ! Element . visible ( paragraphs [ 1 ] ) ) ;
353
+ done ( ) ;
354
+ } , 500 ) ;
346
355
} ) ;
347
356
348
357
test ( '#toggle' , function ( ) {
Original file line number Diff line number Diff line change @@ -83,14 +83,26 @@ div.style-test { margin-left: 1px }
83
83
body {
84
84
height : 40000px ;
85
85
}
86
+
87
+ # test-hidden-by-stylesheet {
88
+ display : none;
89
+ }
90
+
91
+ # iframe {
92
+ width : 1px ;
93
+ height : 1px ;
94
+ }
86
95
</ style >
87
96
88
97
< div id ="scroll_test_1 ">
89
98
< p id ="scroll_test_2 "> Scroll test</ p >
90
99
</ div >
91
100
101
+ < iframe src ="/fixtures/iframe.html " id ="iframe "> </ iframe >
102
+
92
103
< div id ="test-visible "> visible</ div >
93
104
< div id ="test-hidden " style ="display:none; "> hidden</ div >
105
+ < div id ="test-hidden-by-stylesheet "> hidden</ div >
94
106
< div id ="test-toggle-visible "> visible</ div >
95
107
< div id ="test-toggle-hidden " style ="display:none; "> hidden</ div >
96
108
< div id ="test-hide-visible "> visible</ div >
You can’t perform that action at this time.
0 commit comments