選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

73 行
1.6 KiB

  1. define( [
  2. "../core",
  3. "../var/document",
  4. "../manipulation" // appendTo
  5. ], function( jQuery, document ) {
  6. var iframe,
  7. elemdisplay = {
  8. // Support: Firefox
  9. // We have to pre-define these values for FF (#10227)
  10. HTML: "block",
  11. BODY: "block"
  12. };
  13. /**
  14. * Retrieve the actual display of a element
  15. * @param {String} name nodeName of the element
  16. * @param {Object} doc Document object
  17. */
  18. // Called only from within defaultDisplay
  19. function actualDisplay( name, doc ) {
  20. var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  21. display = jQuery.css( elem[ 0 ], "display" );
  22. // We don't have any data stored on the element,
  23. // so use "detach" method as fast way to get rid of the element
  24. elem.detach();
  25. return display;
  26. }
  27. /**
  28. * Try to determine the default display value of an element
  29. * @param {String} nodeName
  30. */
  31. function defaultDisplay( nodeName ) {
  32. var doc = document,
  33. display = elemdisplay[ nodeName ];
  34. if ( !display ) {
  35. display = actualDisplay( nodeName, doc );
  36. // If the simple way fails, read from inside an iframe
  37. if ( display === "none" || !display ) {
  38. // Use the already-created iframe if possible
  39. iframe = ( iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" ) )
  40. .appendTo( doc.documentElement );
  41. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  42. doc = iframe[ 0 ].contentDocument;
  43. // Support: IE
  44. doc.write();
  45. doc.close();
  46. display = actualDisplay( nodeName, doc );
  47. iframe.detach();
  48. }
  49. // Store the correct default display
  50. elemdisplay[ nodeName ] = display;
  51. }
  52. return display;
  53. }
  54. return defaultDisplay;
  55. } );