aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core.js23
-rw-r--r--src/css.js21
-rw-r--r--src/support.js9
-rw-r--r--test/data/support/boxSizing.html19
-rw-r--r--test/unit/support.js5
5 files changed, 54 insertions, 23 deletions
diff --git a/src/core.js b/src/core.js
index 5d8bc3fed..c12d377c7 100644
--- a/src/core.js
+++ b/src/core.js
@@ -865,6 +865,29 @@ jQuery.extend({
now: function() {
return ( new Date() ).getTime();
+ },
+
+ // A method for quickly swapping in/out CSS properties to get correct calculations.
+ // Note: this method belongs to the css module but it's needed here for the support module.
+ // If support gets modularized, this method should be moved back to the css module.
+ swap: function( elem, options, callback, args ) {
+ var ret, name,
+ old = {};
+
+ // Remember the old values, and insert the new ones
+ for ( name in options ) {
+ old[ name ] = elem.style[ name ];
+ elem.style[ name ] = options[ name ];
+ }
+
+ ret = callback.apply( elem, args || [] );
+
+ // Revert the old values
+ for ( name in options ) {
+ elem.style[ name ] = old[ name ];
+ }
+
+ return ret;
}
});
diff --git a/src/css.js b/src/css.js
index 1d1531452..892debf54 100644
--- a/src/css.js
+++ b/src/css.js
@@ -279,27 +279,6 @@ jQuery.extend({
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
}
return val;
- },
-
- // A method for quickly swapping in/out CSS properties to get correct calculations
- swap: function( elem, options, callback, args ) {
- var ret, name,
- old = {};
-
- // Remember the old values, and insert the new ones
- for ( name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
-
- ret = callback.apply( elem, args || [] );
-
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
-
- return ret;
}
});
diff --git a/src/support.js b/src/support.js
index d1cccee2f..0b0bbcc20 100644
--- a/src/support.js
+++ b/src/support.js
@@ -176,10 +176,15 @@ jQuery.support = (function( support ) {
// Check if empty table cells still have offsetWidth/Height
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
- // Check box-sizing and margin behavior
+ // Check box-sizing and margin behavior.
div.innerHTML = "";
div.style.cssText = "box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;";
- support.boxSizing = ( div.offsetWidth === 4 );
+
+ // Workaround failing boxSizing test due to offsetWidth returning wrong value
+ // with some non-1 values of body zoom, ticket #13543
+ jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
+ support.boxSizing = div.offsetWidth === 4;
+ });
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
diff --git a/test/data/support/boxSizing.html b/test/data/support/boxSizing.html
new file mode 100644
index 000000000..2da883dc6
--- /dev/null
+++ b/test/data/support/boxSizing.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <style>
+ body {
+ zoom: 0.87;
+ }
+ </style>
+</head>
+<body>
+<script src="../../jquery.js"></script>
+<script>
+ jQuery(function() {
+ window.parent.iframeCallback( jQuery.support.boxSizing );
+ });
+</script>
+</body>
+</html>
diff --git a/test/unit/support.js b/test/unit/support.js
index 18a1f9a0f..3ee0ca65d 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -28,6 +28,11 @@ if ( jQuery.css ) {
});
}
+testIframeWithCallback( "A non-1 zoom on body doesn't cause WebKit to fail box-sizing test", "support/boxSizing.html", function( boxSizing ) {
+ expect( 1 );
+ equal( boxSizing, jQuery.support.boxSizing, "box-sizing properly detected on page with non-1 body zoom" );
+});
+
testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash.html", function() {
expect( 1 );
ok( true, "IE8 does not crash" );