Sha256: 8bec62bc76ade42ffd1ae486494d869f6ddd1ea173eba5387cf39eae4044f310

Contents?: true

Size: 1.82 KB

Versions: 126

Compression:

Stored size: 1.82 KB

Contents

define([
	"../core",
	"../manipulation" // appendTo
], function( jQuery ) {

var iframe,
	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 style,
		elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),

		// getDefaultComputedStyle might be reliably used only on attached element
		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
			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
	elem.detach();

	return display;
}

/**
 * Try to determine the default display value of an element
 * @param {String} nodeName
 */
function defaultDisplay( nodeName ) {
	var doc = document,
		display = elemdisplay[ nodeName ];

	if ( !display ) {
		display = actualDisplay( nodeName, doc );

		// If the simple way fails, read from inside an iframe
		if ( display === "none" || !display ) {

			// Use the already-created iframe if possible
			iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );

			// Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
			doc = iframe[ 0 ].contentDocument;

			// Support: IE
			doc.write();
			doc.close();

			display = actualDisplay( nodeName, doc );
			iframe.detach();
		}

		// Store the correct default display
		elemdisplay[ nodeName ] = display;
	}

	return display;
}

return defaultDisplay;

});

Version data entries

126 entries across 126 versions & 10 rubygems

Version Path
kms-0.9.0 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
kms-0.8.0 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
TokiCLI-0.3.1 lib/TokiServer/bower_components/jquery/src/css/defaultDisplay.js
kms-0.7.0 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
kms-0.6.0 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
kms-0.5.0 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
kms-0.4.2 vendor/assets/bower_components/jquery/src/css/defaultDisplay.js
wrgem-0.0.55 lib/generators/wrstart/template/vendor/assets/components/jquery/src/css/defaultDisplay.js
wrgem-0.0.54 lib/generators/wrstart/template/vendor/assets/components/jquery/src/css/defaultDisplay.js
praxis-0.19.0 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
wrgem-0.0.53 lib/generators/wrstart/template/vendor/assets/components/jquery/src/css/defaultDisplay.js
wrgem-0.0.52 lib/generators/wrstart/template/vendor/assets/components/jquery/src/css/defaultDisplay.js
wrgem-0.0.51 lib/generators/wrstart/template/vendor/assets/components/jquery/src/css/defaultDisplay.js
praxis-0.18.1 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.18.0 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.17.1 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.17.0 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.16.1 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.16.0 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js
praxis-0.15.0 lib/api_browser/app/bower_components/jquery/src/css/defaultDisplay.js