mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Effects: add back support.shrinkWrapBlocks() for ie6
This commit is contained in:
parent
24ada82ce8
commit
1f85ded204
4
src/effects.js
vendored
4
src/effects.js
vendored
@ -1,6 +1,6 @@
|
||||
define( [
|
||||
"./core",
|
||||
"./support",
|
||||
"./effects/support",
|
||||
"./var/rcssNum",
|
||||
"./var/rnotwhite",
|
||||
"./css/var/cssExpand",
|
||||
@ -133,12 +133,14 @@ function defaultPrefilter( elem, props, opts ) {
|
||||
|
||||
if ( opts.overflow ) {
|
||||
style.overflow = "hidden";
|
||||
if ( !support.shrinkWrapBlocks() ) {
|
||||
anim.always( function() {
|
||||
style.overflow = opts.overflow[ 0 ];
|
||||
style.overflowX = opts.overflow[ 1 ];
|
||||
style.overflowY = opts.overflow[ 2 ];
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
// show/hide pass
|
||||
for ( prop in props ) {
|
||||
|
58
src/effects/support.js
Normal file
58
src/effects/support.js
Normal file
@ -0,0 +1,58 @@
|
||||
define( [
|
||||
"../var/support",
|
||||
"../var/document"
|
||||
], function( support, document ) {
|
||||
|
||||
( function() {
|
||||
var shrinkWrapBlocksVal;
|
||||
|
||||
support.shrinkWrapBlocks = function() {
|
||||
if ( shrinkWrapBlocksVal != null ) {
|
||||
return shrinkWrapBlocksVal;
|
||||
}
|
||||
|
||||
// Will be changed later if needed.
|
||||
shrinkWrapBlocksVal = false;
|
||||
|
||||
// Minified: var b,c,d
|
||||
var div, body, container;
|
||||
|
||||
body = document.getElementsByTagName( "body" )[ 0 ];
|
||||
if ( !body || !body.style ) {
|
||||
|
||||
// Test fired too early or in an unsupported environment, exit.
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup
|
||||
div = document.createElement( "div" );
|
||||
container = document.createElement( "div" );
|
||||
container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
|
||||
body.appendChild( container ).appendChild( div );
|
||||
|
||||
// Support: IE6
|
||||
// Check if elements with layout shrink-wrap their children
|
||||
if ( typeof div.style.zoom !== "undefined" ) {
|
||||
|
||||
// Reset CSS: box-sizing; display; margin; border
|
||||
div.style.cssText =
|
||||
|
||||
// Support: Firefox<29, Android 2.3
|
||||
// Vendor-prefix box-sizing
|
||||
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
|
||||
"box-sizing:content-box;display:block;margin:0;border:0;" +
|
||||
"padding:1px;width:1px;zoom:1";
|
||||
div.appendChild( document.createElement( "div" ) ).style.width = "5px";
|
||||
shrinkWrapBlocksVal = div.offsetWidth !== 3;
|
||||
}
|
||||
|
||||
body.removeChild( container );
|
||||
|
||||
return shrinkWrapBlocksVal;
|
||||
};
|
||||
|
||||
} )();
|
||||
|
||||
return support;
|
||||
|
||||
} );
|
@ -16,8 +16,6 @@ define( [
|
||||
// BuildExclude
|
||||
curCSS = curCSS.curCSS;
|
||||
|
||||
var docElem = window.document.documentElement;
|
||||
|
||||
/**
|
||||
* Gets a window from an element
|
||||
*/
|
||||
@ -162,13 +160,13 @@ jQuery.fn.extend( {
|
||||
|
||||
offsetParent: function() {
|
||||
return this.map( function() {
|
||||
var offsetParent = this.offsetParent || docElem;
|
||||
var offsetParent = this.offsetParent;
|
||||
|
||||
while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) &&
|
||||
jQuery.css( offsetParent, "position" ) === "static" ) ) {
|
||||
offsetParent = offsetParent.offsetParent;
|
||||
}
|
||||
return offsetParent || docElem;
|
||||
return offsetParent || documentElement;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
23
test/data/support/shrinkWrapBlocks.html
Normal file
23
test/data/support/shrinkWrapBlocks.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
* {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<script src="../../jquery.js"></script>
|
||||
</div>
|
||||
<script>
|
||||
jQuery(function() {
|
||||
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks() );
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -209,7 +209,9 @@ QUnit.test( "manipulation", function( assert ) {
|
||||
QUnit.test( "offset", function( assert ) {
|
||||
assert.expect( 3 );
|
||||
|
||||
var parent = jQuery( "<div style='position:fixed;top:20px;'/>" ).appendTo( "#qunit-fixture" ),
|
||||
var parent =
|
||||
jQuery( "<div style='position:fixed;_position:absolute;top:20px;'/>" )
|
||||
.appendTo( "body" ),
|
||||
elem = jQuery( "<div style='position:absolute;top:5px;'/>" ).appendTo( parent );
|
||||
|
||||
assert.strictEqual( elem.offset().top, 25, ".offset getter" );
|
||||
|
33
test/unit/effects.js
vendored
33
test/unit/effects.js
vendored
@ -1049,10 +1049,11 @@ jQuery.each( {
|
||||
|
||||
QUnit.test( "Effects chaining", function() {
|
||||
var remaining = 16,
|
||||
shrinkwrap = jQuery.support.shrinkWrapBlocks(),
|
||||
props = [ "opacity", "height", "width", "display", "overflow" ],
|
||||
setup = function( name, selector ) {
|
||||
setup = function( name, selector, hiddenOverflow ) {
|
||||
var $el = jQuery( selector );
|
||||
return $el.data( getProps( $el[0] ) ).data( "name", name );
|
||||
return $el.data( getProps( $el[0], hiddenOverflow ) ).data( "name", name );
|
||||
},
|
||||
assert = function() {
|
||||
var data = jQuery.data( this ),
|
||||
@ -1073,19 +1074,21 @@ QUnit.test( "Effects chaining", function() {
|
||||
|
||||
expect( remaining );
|
||||
|
||||
// We need to pass jQuery.support.shrinkWrapBlocks for all methods that
|
||||
// set overflow hidden (slide* and show/hide with speed)
|
||||
setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", assert );
|
||||
setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", assert );
|
||||
setup( ".hide().show()", "#show div" ).hide("fast").show( "fast", assert );
|
||||
setup( ".show().hide()", "#hide div" ).show("fast").hide( "fast", assert );
|
||||
setup( ".show().hide(easing)", "#easehide div" ).show("fast").hide( "fast", "linear", assert );
|
||||
setup( ".toggle().toggle() - in", "#togglein div" ).toggle("fast").toggle( "fast", assert );
|
||||
setup( ".toggle().toggle() - out", "#toggleout div" ).toggle("fast").toggle( "fast", assert );
|
||||
setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle("fast").toggle( "fast", "linear", assert );
|
||||
setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown("fast").slideUp( "fast", assert );
|
||||
setup( ".slideUp().slideDown()", "#slideup div" ).slideUp("fast").slideDown( "fast", assert );
|
||||
setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp("fast").slideDown( "fast", "linear", assert );
|
||||
setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle("fast").slideToggle( "fast", assert );
|
||||
setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle("fast").slideToggle( "fast", assert );
|
||||
setup( ".hide().show()", "#show div", shrinkwrap ).hide("fast").show( "fast", assert );
|
||||
setup( ".show().hide()", "#hide div", shrinkwrap ).show("fast").hide( "fast", assert );
|
||||
setup( ".show().hide(easing)", "#easehide div", shrinkwrap ).show("fast").hide( "fast", "linear", assert );
|
||||
setup( ".toggle().toggle() - in", "#togglein div", shrinkwrap ).toggle("fast").toggle( "fast", assert );
|
||||
setup( ".toggle().toggle() - out", "#toggleout div", shrinkwrap ).toggle("fast").toggle( "fast", assert );
|
||||
setup( ".toggle().toggle(easing) - out", "#easetoggleout div", shrinkwrap ).toggle("fast").toggle( "fast", "linear", assert );
|
||||
setup( ".slideDown().slideUp()", "#slidedown div", shrinkwrap ).slideDown("fast").slideUp( "fast", assert );
|
||||
setup( ".slideUp().slideDown()", "#slideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", assert );
|
||||
setup( ".slideUp().slideDown(easing)", "#easeslideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", "linear", assert );
|
||||
setup( ".slideToggle().slideToggle() - in", "#slidetogglein div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert );
|
||||
setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert );
|
||||
setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert );
|
||||
setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert );
|
||||
setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert );
|
||||
@ -1919,8 +1922,12 @@ QUnit.test( "Animate properly sets overflow hidden when animating width/height (
|
||||
equal( div.css( "overflow" ), "hidden",
|
||||
"overflow: hidden set when animating " + prop + " to " + value );
|
||||
div.stop();
|
||||
if ( jQuery.support.shrinkWrapBlocks() ) {
|
||||
ok( true, "cannot restore overflow, shrinkWrapBlocks" );
|
||||
} else {
|
||||
equal( div.css( "overflow" ), "auto",
|
||||
"overflow: auto restored after animating " + prop + " to " + value );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
@ -25,7 +25,7 @@ QUnit.test( "zoom of doom (#13089)", function( assert ) {
|
||||
} else {
|
||||
ok( !document.body.style.zoom, "No zoom added to the body" );
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
if ( jQuery.css ) {
|
||||
testIframeWithCallback(
|
||||
@ -48,6 +48,18 @@ if ( jQuery.css ) {
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
testIframeWithCallback(
|
||||
"box-sizing does not affect jQuery.support.shrinkWrapBlocks",
|
||||
"support/shrinkWrapBlocks.html",
|
||||
function( shrinkWrapBlocks, assert ) {
|
||||
assert.expect( 1 );
|
||||
assert.strictEqual(
|
||||
shrinkWrapBlocks,
|
||||
computedSupport.shrinkWrapBlocks,
|
||||
"jQuery.support.shrinkWrapBlocks properties are the same"
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
testIframeWithCallback(
|
||||
@ -116,6 +128,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -156,6 +169,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -196,6 +210,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -236,6 +251,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -276,6 +292,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": false,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": false,
|
||||
"submit": false,
|
||||
"tbody": true
|
||||
@ -316,6 +333,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": false,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": false,
|
||||
"submit": false,
|
||||
"tbody": false
|
||||
@ -356,6 +374,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": false,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": true,
|
||||
"style": false,
|
||||
"submit": false,
|
||||
"tbody": false
|
||||
@ -399,6 +418,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -439,6 +459,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -479,6 +500,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -519,6 +541,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -559,6 +582,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -599,6 +623,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": false,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -639,6 +664,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -679,6 +705,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -719,6 +746,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -759,6 +787,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -799,6 +828,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
@ -839,6 +869,7 @@ testIframeWithCallback(
|
||||
"reliableHiddenOffsets": true,
|
||||
"reliableMarginRight": true,
|
||||
"reliableMarginLeft": true,
|
||||
"shrinkWrapBlocks": false,
|
||||
"style": true,
|
||||
"submit": true,
|
||||
"tbody": true
|
||||
|
Loading…
Reference in New Issue
Block a user