From: Oleg Date: Tue, 17 Sep 2013 11:47:31 +0000 (+0400) Subject: Fix #12723 and simplification and optmization of defaultDisplay helper X-Git-Tag: 2.1.0-beta1~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a25343001eea2436dcf8ea60deea3844f77e42e4;p=jquery.git Fix #12723 and simplification and optmization of defaultDisplay helper --- diff --git a/src/css/defaultDisplay.js b/src/css/defaultDisplay.js index 78acb2bcd..45af9f90f 100644 --- a/src/css/defaultDisplay.js +++ b/src/css/defaultDisplay.js @@ -4,17 +4,28 @@ define([ ], function( jQuery ) { var iframe, - elemdisplay = { BODY: "block" }; + elemdisplay = {}; /** * Retrieve the actual display of a element * @param {String} name nodeName of the element * @param {Object} doc Document object */ +// Called only from within defaultDisplay function actualDisplay( name, doc ) { var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), - display = jQuery.css( elem[0], "display" ); - elem.remove(); + + // getDefaultComputedStyle might be reliably used only on attached element + display = window.getDefaultComputedStyle ? + + // 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" ); + + // We don't have any data stored on the element, + // so use "detach" method as fast way to get rid of the element + elem.detach(); + return display; } @@ -31,15 +42,15 @@ function defaultDisplay( nodeName ) { // If the simple way fails, read from inside an iframe if ( display === "none" || !display ) { + // Use the already-created iframe if possible - iframe = ( iframe || - jQuery("