Skip to content
Permalink
Browse files

CSS: window.getDefaultComputedStyle may return null

Fixes #14736
Closes gh-1501
(cherry picked from commit 51910ba8a5aff4cd1a811f1fdb76a6c62a09a666)
  • Loading branch information
rosenfeld authored and dmethvin committed Jan 28, 2014
1 parent ca0086b commit e547a2775fc79e4b2eb807da9d30719afc570458
Showing with 5 additions and 3 deletions.
  1. +1 −0 AUTHORS.txt
  2. +4 −3 src/css/defaultDisplay.js
@@ -218,4 +218,5 @@ Forbes Lindesay <forbes@lindesay.co.uk>
S. Andrew Sheppard <andrew@wq.io>
Roman Reiß <me@silverwind.io>
Benjy Cui <benjytrys@gmail.com>
Rodrigo Rosenfeld Rosas <rr.rosas@gmail.com>

@@ -13,14 +13,15 @@ var iframe,
*/
// Called only from within defaultDisplay
function actualDisplay( name, doc ) {
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
var style,
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),

// getDefaultComputedStyle might be reliably used only on attached element
display = window.getDefaultComputedStyle ?
display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?

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

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

0 comments on commit e547a27

Please sign in to comment.
You can’t perform that action at this time.