Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix 8985,use DocumentFragment get the default display value of an ele…

…ment in domian set page avoid iframe error
  • Loading branch information...
commit 6586b11b968cfb90cb3aaa5cc5688197130ec5b5 1 parent 2667b57
cmc3cn authored April 29, 2011

Showing 1 changed file with 24 additions and 18 deletions. Show diff stats Hide diff stats

  1. 42  src/effects.js
42  src/effects.js
... ...
@@ -1,7 +1,7 @@
1 1
 (function( jQuery ) {
2 2
 
3 3
 var elemdisplay = {},
4  
-	iframe, iframeDoc,
  4
+	iframe, iframeDoc, fragment,
5 5
 	rfxtypes = /^(?:toggle|show|hide)$/,
6 6
 	rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
7 7
 	timerId,
@@ -585,24 +585,30 @@ function defaultDisplay( nodeName ) {
585 585
 				iframe = document.createElement( "iframe" );
586 586
 				iframe.frameBorder = iframe.width = iframe.height = 0;
587 587
 			}
588  
-
589  
-			document.body.appendChild( iframe );
590  
-
591  
-			// Create a cacheable copy of the iframe document on first call.
592  
-			// IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
593  
-			// document to it, Webkit & Firefox won't allow reusing the iframe document
594  
-			if ( !iframeDoc || !iframe.createElement ) {
595  
-				iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
  588
+			if (!fragment) {
  589
+				document.body.appendChild( iframe );
  590
+				try {
  591
+					iframeDoc = iframe.contentDocument || iframe.contentWindow.document;				
  592
+				}
  593
+				catch(e){					
  594
+					document.body.removeChild( iframe );
  595
+					fragment = document.createDocumentFragment();
  596
+				}
  597
+			}			
  598
+			
  599
+			if(iframeDoc){
596 600
 				iframeDoc.write( "<!doctype><html><body></body></html>" );
597  
-			}
598  
-
599  
-			elem = iframeDoc.createElement( nodeName );
600  
-
601  
-			iframeDoc.body.appendChild( elem );
602  
-
603  
-			display = jQuery.css( elem, "display" );
604  
-
605  
-			document.body.removeChild( iframe );
  601
+				iframeDoc.close();				
  602
+				elem = iframeDoc.createElement( nodeName );
  603
+				iframeDoc.body.appendChild( elem );
  604
+				display = jQuery.css( elem, "display" );
  605
+				document.body.removeChild( iframe );
  606
+			}else{
  607
+				elem = document.createElement( nodeName );
  608
+				fragment.appendChild( elem );
  609
+				display = elem.currentStyle.display;
  610
+				fragment.removeChild( elem );
  611
+			}			
606 612
 		}
607 613
 
608 614
 		// Store the correct default display

0 notes on commit 6586b11

Please sign in to comment.
Something went wrong with that request. Please try again.