Skip to content

Commit 1034428

Browse files
author
Martin Naumann
committed
CSS: dimensions workaround for IE11 fullscreen quirk
Fixes #1764
1 parent b041242 commit 1034428

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

src/css.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,18 @@ function getWidthOrHeight( elem, name, extra ) {
113113
styles = getStyles( elem ),
114114
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
115115

116+
// Support: IE11+
117+
// Fix for edge case in IE 11. See https://github.com/jquery/jquery/issues/1764
118+
if ( !support.reliableFullscreenBox && window.top !== window.self &&
119+
document.msFullscreenElement ) {
120+
// Support: IE<=11+
121+
// Running getBoundingClientRect on a
122+
// disconnected node in IE throws an error
123+
if ( elem.getClientRects().length ) {
124+
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
125+
}
126+
}
127+
116128
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
117129
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
118130
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668

src/css/support.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,12 @@ define([
9696
div.removeChild( marginDiv );
9797

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

test/unit/support.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
6767
"pixelMarginRight": true,
6868
"pixelPosition": true,
6969
"radioValue": true,
70+
"reliableFullscreenBox": true,
7071
"reliableMarginRight": true
7172
};
72-
} else if ( /(msie 10\.0|trident\/7\.0)/i.test( userAgent ) ) {
73+
} else if ( /trident\/7\.0/i.test( userAgent ) ) {
7374
expected = {
7475
"ajax": true,
7576
"boxSizingReliable": false,
@@ -85,6 +86,26 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
8586
"pixelMarginRight": true,
8687
"pixelPosition": true,
8788
"radioValue": false,
89+
"reliableFullscreenBox": false,
90+
"reliableMarginRight": true
91+
};
92+
} else if ( /msie 10\.0/i.test( userAgent ) ) {
93+
expected = {
94+
"ajax": true,
95+
"boxSizingReliable": false,
96+
"checkClone": true,
97+
"checkOn": true,
98+
"clearCloneStyle": false,
99+
"cors": true,
100+
"createHTMLDocument": true,
101+
"focusin": true,
102+
"noCloneChecked": false,
103+
"optDisabled": true,
104+
"optSelected": false,
105+
"pixelMarginRight": true,
106+
"pixelPosition": true,
107+
"radioValue": false,
108+
"reliableFullscreenBox": true,
88109
"reliableMarginRight": true
89110
};
90111
} else if ( /msie 9\.0/i.test( userAgent ) ) {
@@ -103,6 +124,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
103124
"pixelMarginRight": true,
104125
"pixelPosition": true,
105126
"radioValue": false,
127+
"reliableFullscreenBox": true,
106128
"reliableMarginRight": true
107129
};
108130
} else if ( /chrome/i.test( userAgent ) ) {
@@ -123,6 +145,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
123145
"pixelMarginRight": true,
124146
"pixelPosition": true,
125147
"radioValue": true,
148+
"reliableFullscreenBox": true,
126149
"reliableMarginRight": true
127150
};
128151
} else if ( /8\.0(\.\d+|) safari/i.test( userAgent ) ) {
@@ -141,6 +164,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
141164
"pixelMarginRight": true,
142165
"pixelPosition": false,
143166
"radioValue": true,
167+
"reliableFullscreenBox": true,
144168
"reliableMarginRight": true
145169
};
146170
} else if ( /(6|7)\.0(\.\d+|) safari/i.test( userAgent ) ) {
@@ -159,6 +183,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
159183
"pixelMarginRight": true,
160184
"pixelPosition": false,
161185
"radioValue": true,
186+
"reliableFullscreenBox": true,
162187
"reliableMarginRight": true
163188
};
164189
} else if ( /firefox/i.test( userAgent ) ) {
@@ -177,6 +202,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
177202
"pixelMarginRight": true,
178203
"pixelPosition": true,
179204
"radioValue": true,
205+
"reliableFullscreenBox": true,
180206
"reliableMarginRight": true
181207
};
182208
} else if ( /iphone os 8/i.test( userAgent ) ) {
@@ -195,6 +221,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
195221
"pixelMarginRight": true,
196222
"pixelPosition": false,
197223
"radioValue": true,
224+
"reliableFullscreenBox": true,
198225
"reliableMarginRight": true
199226
};
200227
} else if ( /iphone os (6|7)/i.test( userAgent ) ) {
@@ -213,6 +240,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
213240
"pixelMarginRight": true,
214241
"pixelPosition": false,
215242
"radioValue": true,
243+
"reliableFullscreenBox": true,
216244
"reliableMarginRight": true
217245
};
218246
} else if ( /android 4\.[0-3]/i.test( userAgent ) ) {
@@ -231,6 +259,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
231259
"pixelMarginRight": false,
232260
"pixelPosition": false,
233261
"radioValue": true,
262+
"reliableFullscreenBox": true,
234263
"reliableMarginRight": true
235264
};
236265
} else if ( /android 2\.3/i.test( userAgent ) ) {
@@ -249,6 +278,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec
249278
"pixelMarginRight": true,
250279
"pixelPosition": false,
251280
"radioValue": true,
281+
"reliableFullscreenBox": true,
252282
"reliableMarginRight": false
253283
};
254284
}

0 commit comments

Comments
 (0)