Skip to content
Browse files

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

…ment in domian set page avoid iframe error
  • Loading branch information...
1 parent 2667b57 commit 6586b11b968cfb90cb3aaa5cc5688197130ec5b5 @cmc3cn cmc3cn committed
Showing with 24 additions and 18 deletions.
  1. +24 −18 src/effects.js
View
42 src/effects.js
@@ -1,7 +1,7 @@
(function( jQuery ) {
var elemdisplay = {},
- iframe, iframeDoc,
+ iframe, iframeDoc, fragment,
rfxtypes = /^(?:toggle|show|hide)$/,
rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
timerId,
@@ -585,24 +585,30 @@ function defaultDisplay( nodeName ) {
iframe = document.createElement( "iframe" );
iframe.frameBorder = iframe.width = iframe.height = 0;
}
-
- document.body.appendChild( iframe );
-
- // Create a cacheable copy of the iframe document on first call.
- // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake html
- // document to it, Webkit & Firefox won't allow reusing the iframe document
- if ( !iframeDoc || !iframe.createElement ) {
- iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
+ if (!fragment) {
+ document.body.appendChild( iframe );
+ try {
+ iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
+ }
+ catch(e){
+ document.body.removeChild( iframe );
+ fragment = document.createDocumentFragment();
+ }
+ }
+
+ if(iframeDoc){
iframeDoc.write( "<!doctype><html><body></body></html>" );
- }
-
- elem = iframeDoc.createElement( nodeName );
-
- iframeDoc.body.appendChild( elem );
-
- display = jQuery.css( elem, "display" );
-
- document.body.removeChild( iframe );
+ iframeDoc.close();
+ elem = iframeDoc.createElement( nodeName );
+ iframeDoc.body.appendChild( elem );
+ display = jQuery.css( elem, "display" );
+ document.body.removeChild( iframe );
+ }else{
+ elem = document.createElement( nodeName );
+ fragment.appendChild( elem );
+ display = elem.currentStyle.display;
+ fragment.removeChild( elem );
+ }
}
// Store the correct default display

0 comments on commit 6586b11

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