MCPcopy Index your code
hub / github.com/JsAaron/jQuery / defaultDisplay

Function defaultDisplay

1.6.1/src/effects.js:573–615  ·  view source on GitHub ↗
( nodeName )

Source from the content-addressed store, hash-verified

571
572// Try to restore the default display value of an element
573function defaultDisplay( nodeName ) {
574
575 if ( !elemdisplay[ nodeName ] ) {
576
577 var elem = jQuery( "<" + nodeName + ">" ).appendTo( "body" ),
578 display = elem.css( "display" );
579
580 elem.remove();
581
582 // If the simple way fails,
583 // get element's real default display by attaching it to a temp iframe
584 if ( display === "none" || display === "" ) {
585 // No iframe to use yet, so create it
586 if ( !iframe ) {
587 iframe = document.createElement( "iframe" );
588 iframe.frameBorder = iframe.width = iframe.height = 0;
589 }
590
591 document.body.appendChild( iframe );
592
593 // Create a cacheable copy of the iframe document on first call.
594 // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
595 // document to it, Webkit & Firefox won't allow reusing the iframe document
596 if ( !iframeDoc || !iframe.createElement ) {
597 iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
598 iframeDoc.write( "<!doctype><html><body></body></html>" );
599 }
600
601 elem = iframeDoc.createElement( nodeName );
602
603 iframeDoc.body.appendChild( elem );
604
605 display = jQuery.css( elem, "display" );
606
607 document.body.removeChild( iframe );
608 }
609
610 // Store the correct default display
611 elemdisplay[ nodeName ] = display;
612 }
613
614 return elemdisplay[ nodeName ];
615}
616
617})( jQuery );

Callers 1

effects.jsFile · 0.70

Calls 1

jQueryFunction · 0.70

Tested by

no test coverage detected