Skip to content

Commit e547a27

Browse files
rosenfelddmethvin
authored andcommitted
CSS: window.getDefaultComputedStyle may return null
Fixes #14736 Closes jquerygh-1501 (cherry picked from commit 51910ba8a5aff4cd1a811f1fdb76a6c62a09a666)
1 parent ca0086b commit e547a27

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,5 @@ Forbes Lindesay <forbes@lindesay.co.uk>
218218
S. Andrew Sheppard <andrew@wq.io>
219219
Roman Reiß <me@silverwind.io>
220220
Benjy Cui <benjytrys@gmail.com>
221+
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>
221222

src/css/defaultDisplay.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ var iframe,
1313
*/
1414
// Called only from within defaultDisplay
1515
function actualDisplay( name, doc ) {
16-
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
16+
var style,
17+
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
1718

1819
// getDefaultComputedStyle might be reliably used only on attached element
19-
display = window.getDefaultComputedStyle ?
20+
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
2021

2122
// Use of this method is a temporary fix (more like optmization) until something better comes along,
2223
// since it was removed from specification and supported only in FF
23-
window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
24+
style.display : jQuery.css( elem[ 0 ], "display" );
2425

2526
// We don't have any data stored on the element,
2627
// so use "detach" method as fast way to get rid of the element

0 commit comments

Comments
 (0)