Skip to content

Commit

Permalink
CSS: dimensions workaround for IE11 fullscreen quirk
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Naumann committed Jun 17, 2015
1 parent b041242 commit 1034428
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/css.js
Expand Up @@ -113,6 +113,18 @@ function getWidthOrHeight( elem, name, extra ) {
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";

// Support: IE11+
// Fix for edge case in IE 11. See https://github.com/jquery/jquery/issues/1764
if ( !support.reliableFullscreenBox && window.top !== window.self &&
document.msFullscreenElement ) {
// Support: IE<=11+
// Running getBoundingClientRect on a
// disconnected node in IE throws an error
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
}

// Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
Expand Down
7 changes: 6 additions & 1 deletion src/css/support.js
Expand Up @@ -96,7 +96,12 @@ define([
div.removeChild( marginDiv );

return ret;
}
},
// Support: IE 11
// IE 11 has a bug with offsetWidth / offsetHeight / getClientBoundingRect()
// in fullscreen mode inside an iframe the values are 100x smaller than they should be
// See https://connect.microsoft.com/IE/feedback/details/838286
reliableFullscreenBox: !( "msFullscreenElement" in document )
});
})();

Expand Down
32 changes: 31 additions & 1 deletion test/unit/support.js
Expand Up @@ -67,9 +67,10 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
} else if ( /trident\/7\.0/i.test( userAgent ) ) {
expected = {
"ajax": true,
"boxSizingReliable": false,
Expand All @@ -85,6 +86,26 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": false,
"reliableFullscreenBox": false,
"reliableMarginRight": true
};
} else if ( /msie 10\.0/i.test( userAgent ) ) {
expected = {
"ajax": true,
"boxSizingReliable": false,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
"cors": true,
"createHTMLDocument": true,
"focusin": true,
"noCloneChecked": false,
"optDisabled": true,
"optSelected": false,
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": false,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /msie 9\.0/i.test( userAgent ) ) {
Expand All @@ -103,6 +124,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": false,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /chrome/i.test( userAgent ) ) {
Expand All @@ -123,6 +145,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /8\.0(\.\d+|) safari/i.test( userAgent ) ) {
Expand All @@ -141,6 +164,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /(6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
Expand All @@ -159,6 +183,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /firefox/i.test( userAgent ) ) {
Expand All @@ -177,6 +202,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": true,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /iphone os 8/i.test( userAgent ) ) {
Expand All @@ -195,6 +221,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /iphone os (6|7)/i.test( userAgent ) ) {
Expand All @@ -213,6 +240,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
Expand All @@ -231,6 +259,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": false,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": true
};
} else if ( /android 2\.3/i.test( userAgent ) ) {
Expand All @@ -249,6 +278,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
"pixelMarginRight": true,
"pixelPosition": false,
"radioValue": true,
"reliableFullscreenBox": true,
"reliableMarginRight": false
};
}
Expand Down

0 comments on commit 1034428

Please sign in to comment.