aboutsummaryrefslogtreecommitdiffstats
path: root/src/css/support.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/css/support.js')
-rw-r--r--src/css/support.js96
1 files changed, 26 insertions, 70 deletions
diff --git a/src/css/support.js b/src/css/support.js
index 9c4da57d9..65763baec 100644
--- a/src/css/support.js
+++ b/src/css/support.js
@@ -9,58 +9,7 @@ define( [
( function() {
- // Executing both pixelPosition & boxSizingReliable tests require only one layout
- // so they're executed at the same time to save the second computation.
- function computeStyleTests() {
-
- // This is a singleton, we need to execute it only once
- if ( !div ) {
- return;
- }
-
- container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
- "margin-top:1px;padding:0;border:0";
- div.style.cssText =
- "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
- "margin:auto;border:1px;padding:1px;" +
- "width:60%;top:1%";
- documentElement.appendChild( container ).appendChild( div );
-
- var divStyle = window.getComputedStyle( div );
- pixelPositionVal = divStyle.top !== "1%";
-
- // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
- reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
-
- // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
- // Some styles come back with percentage values, even though they shouldn't
- div.style.right = "60%";
- pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
-
- // Support: IE 9 - 11 only
- // Detect misreporting of content dimensions for box-sizing:border-box elements
- boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
-
- // Support: IE 9 only
- // Detect overflow:scroll screwiness (gh-3699)
- // Support: Chrome <=64
- // Don't get tricked when zoom affects offsetWidth (gh-4029)
- div.style.position = "absolute";
- scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
-
- documentElement.removeChild( container );
-
- // Nullify the div so it wouldn't be stored in the memory and
- // it will also be a sign that checks already performed
- div = null;
- }
-
- function roundPixelMeasures( measure ) {
- return Math.round( parseFloat( measure ) );
- }
-
- var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
- reliableMarginLeftVal,
+ var boxSizingReliableVal,
container = document.createElement( "div" ),
div = document.createElement( "div" );
@@ -69,7 +18,7 @@ define( [
return;
}
- // Support: IE <=9 - 11 only
+ // Support: IE <=9 - 11+
// Style of cloned element affects source element cloned (#8908)
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
@@ -77,24 +26,31 @@ define( [
jQuery.extend( support, {
boxSizingReliable: function() {
- computeStyleTests();
+
+ // This is a singleton, we need to execute it only once
+ if ( div ) {
+ container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
+ "margin-top:1px;padding:0;border:0";
+ div.style.cssText =
+ "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
+ "margin:auto;border:1px;padding:1px;" +
+ "width:60%;top:1%";
+ documentElement.appendChild( container ).appendChild( div );
+
+ var divStyle = window.getComputedStyle( div );
+
+ // Support: IE 9 - 11+
+ // Detect misreporting of content dimensions for box-sizing:border-box elements
+ boxSizingReliableVal = Math.round( parseFloat( divStyle.width ) ) === 36;
+
+ documentElement.removeChild( container );
+
+ // Nullify the div so it wouldn't be stored in the memory and
+ // it will also be a sign that checks already performed
+ div = null;
+ }
+
return boxSizingReliableVal;
- },
- pixelBoxStyles: function() {
- computeStyleTests();
- return pixelBoxStylesVal;
- },
- pixelPosition: function() {
- computeStyleTests();
- return pixelPositionVal;
- },
- reliableMarginLeft: function() {
- computeStyleTests();
- return reliableMarginLeftVal;
- },
- scrollboxSize: function() {
- computeStyleTests();
- return scrollboxSizeVal;
}
} );
} )();