Fix #10814. Fix #14084. Make support tests lazy and broken out to components.

This commit is contained in:
Michał Gołębiowski 2013-09-02 19:21:09 +02:00
parent 9035cab8c8
commit badcd1b6f3
35 changed files with 1035 additions and 633 deletions

View File

@ -5,3 +5,5 @@ test/data/badjson.js
test/data/json_obj.js
test/data/readywaitasset.js
test/data/readywaitloader.js
test/data/support/csp.js
test/data/support/getComputedSupport.js

View File

@ -88,11 +88,10 @@ Some example modules that can be excluded are:
- **exports/amd**: Exclude the AMD definition.
- **core/ready**: Exclude the ready module if you place your scripts at the end of the body. Any ready callbacks bound with `jQuery()` will simply be called immediately. However, `jQuery(document).ready()` will not be a function and `.on("ready", ...)` or similar will not be triggered.
- **deferred**: Exclude jQuery.Deferred. This also removes jQuery.Callbacks. *Note* that modules that depend on jQuery.Deferred(AJAX, effects, core/ready) will not be removed and will still expect jQuery.Deferred to be there. Include your own jQuery.Deferred implementation or exclude those modules as well (`grunt custom:-deferred,-ajax,-effects,-core/ready`).
- **support**: Excluding the support module is not recommended, but possible. It's your responsibility to either remove modules that use jQuery.support (many of them) or replace the values wherever jQuery.support is used. This is mainly only useful when building a barebones version of jQuery.
Removing sizzle is not supported on the 1.x branch.
*Note*: Excluding Sizzle will also exclude all jQuery selector extensions (such as `effects/animated-selector` and `css/hidden-visible-selectors`).
*Note*: Excluding Sizzle will also exclude all jQuery selector extensions (such as `effects/animatedSelector` and `css/hiddenVisibleSelectors`).
The build process shows a message for each dependent module it excludes or includes.

View File

@ -1,8 +1,8 @@
define([
"../core",
"../ajax",
"../support"
], function( jQuery ) {
"../var/support",
"../ajax"
], function( jQuery, support ) {
var xhrCallbacks, xhrSupported,
xhrId = 0,
@ -45,15 +45,15 @@ jQuery.ajaxSettings.xhr = window.ActiveXObject ?
// Determine support properties
xhrSupported = jQuery.ajaxSettings.xhr();
jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
xhrSupported = jQuery.support.ajax = !!xhrSupported;
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
xhrSupported = support.ajax = !!xhrSupported;
// Create transport if the browser can provide an xhr
if ( xhrSupported ) {
jQuery.ajaxTransport(function( s ) {
// Cross domain only allowed if supported through XMLHttpRequest
if ( !s.crossDomain || jQuery.support.cors ) {
if ( !s.crossDomain || support.cors ) {
var callback;

View File

@ -2,16 +2,16 @@ define([
"../core",
"../var/rnotwhite",
"../var/strundefined",
"./support",
"./val",
"../selector",
"../support"
], function( jQuery, rnotwhite, strundefined ) {
"../selector"
], function( jQuery, rnotwhite, strundefined, support ) {
var nodeHook, boolHook,
attrHandle = jQuery.expr.attrHandle,
ruseDefault = /^(?:checked|selected)$/i,
getSetAttribute = jQuery.support.getSetAttribute,
getSetInput = jQuery.support.input;
getSetAttribute = support.getSetAttribute,
getSetInput = support.input;
jQuery.fn.extend({
attr: function( name, value ) {
@ -108,7 +108,7 @@ jQuery.extend({
attrHooks: {
type: {
set: function( elem, value ) {
if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to default in case type is set after value during creation
var val = elem.value;
@ -253,7 +253,7 @@ if ( !getSetAttribute ) {
});
}
if ( !jQuery.support.style ) {
if ( !support.style ) {
jQuery.attrHooks.style = {
get: function( elem ) {
// Return undefined in the case of empty string

View File

@ -1,7 +1,7 @@
define([
"../core",
"../support"
], function( jQuery ) {
"./support"
], function( jQuery, support ) {
var rfocusable = /^(?:input|select|textarea|button|object)$/i,
rclickable = /^(?:a|area)$/i;
@ -78,7 +78,7 @@ jQuery.extend({
// Some attributes require a special call on IE
// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
if ( !jQuery.support.hrefNormalized ) {
if ( !support.hrefNormalized ) {
// href/src property should get the full normalized URL (#10299/#12915)
jQuery.each([ "href", "src" ], function( i, name ) {
jQuery.propHooks[ name ] = {
@ -92,7 +92,7 @@ if ( !jQuery.support.hrefNormalized ) {
// Support: Safari, IE9+
// mis-reports the default selected property of an option
// Accessing the parent's selectedIndex property fixes it
if ( !jQuery.support.optSelected ) {
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
var parent = elem.parentNode;
@ -126,7 +126,7 @@ jQuery.each([
});
// IE6/7 call enctype encoding
if ( !jQuery.support.enctype ) {
if ( !support.enctype ) {
jQuery.propFix.enctype = "encoding";
}

63
src/attributes/support.js Normal file
View File

@ -0,0 +1,63 @@
define([
"../var/support"
], function( support ) {
(function () {
var a, input, select, opt,
div = document.createElement("div" );
// Setup
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
a = div.getElementsByTagName("a")[ 0 ];
// First batch of tests.
select = document.createElement("select");
opt = select.appendChild( document.createElement("option") );
input = div.getElementsByTagName("input")[ 0 ];
a.style.cssText = "top:1px";
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
support.getSetAttribute = div.className !== "t";
// Get the style information from getAttribute
// (IE uses .cssText instead)
support.style = /top/.test( a.getAttribute("style") );
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
support.hrefNormalized = a.getAttribute("href") === "/a";
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
support.checkOn = !!input.value;
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
support.optSelected = opt.selected;
// Tests for enctype support on a form (#6743)
support.enctype = !!document.createElement("form").enctype;
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as disabled)
select.disabled = true;
support.optDisabled = !opt.disabled;
// Check if we can trust getAttribute("value")
input = document.createElement("input");
input.setAttribute( "value", "" );
support.input = input.getAttribute( "value" ) === "";
// Check if an input maintains its value after becoming a radio
input.value = "t";
input.setAttribute( "type", "radio" );
support.radioValue = input.value === "t";
// Null elements to avoid leaks in IE.
a = input = select = opt = div = null;
})();
return support;
});

View File

@ -1,7 +1,7 @@
define([
"../core",
"../support"
], function( jQuery ) {
"./support"
], function( jQuery, support ) {
var rreturn = /\r/g;
@ -96,7 +96,7 @@ jQuery.extend({
// oldIE doesn't update selected after form reset (#2551)
if ( ( option.selected || i === index ) &&
// Don't return options that are disabled or in a disabled optgroup
( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
@ -147,7 +147,7 @@ jQuery.each([ "radio", "checkbox" ], function() {
}
}
};
if ( !jQuery.support.checkOn ) {
if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) {
// Support: Webkit
// "" is returned instead of "on" if a value isn't specified

View File

@ -9,11 +9,14 @@ define([
"./var/class2type",
"./var/toString",
"./var/hasOwn",
"./var/trim"
"./var/trim",
"./var/support"
], function( strundefined, deletedIds, slice, concat, push, indexOf,
class2type, toString, hasOwn, trim ) {
class2type, toString, hasOwn, trim, support ) {
var
i,
// A central reference to the root jQuery(document)
rootjQuery,
@ -364,43 +367,6 @@ jQuery.extend({
typeof obj;
},
isPlainObject: function( obj ) {
var key;
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
// Support: IE<9
// Handle iteration over inherited properties before own properties.
if ( jQuery.support.ownLast ) {
for ( key in obj ) {
return hasOwn.call( obj, key );
}
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
for ( key in obj ) {}
return key === undefined || hasOwn.call( obj, key );
},
isEmptyObject: function( obj ) {
var name;
for ( name in obj ) {
@ -789,6 +755,60 @@ jQuery.extend({
now: function() {
return ( new Date() ).getTime();
},
// jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist.
support: support
});
// Support: IE<9
// Iteration over object's inherited properties before its own.
// It would be better to move this test to one of test modules but since
// tests require the jQuery object to exist as well as some other variables set
// core initialization is needed first for tests used in core itself.
for ( i in jQuery( support ) ) {
break;
}
support.ownLast = i !== "0";
jQuery.extend({
isPlainObject: function( obj ) {
var key;
// Must be an Object.
// Because of IE, we also have to check the presence of the constructor property.
// Make sure that DOM nodes and window objects don't pass through, as well
if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
return false;
}
try {
// Not own constructor property must be Object
if ( obj.constructor &&
!hasOwn.call(obj, "constructor") &&
!hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
return false;
}
} catch ( e ) {
// IE8,9 Will throw exceptions on certain host objects #9897
return false;
}
// Support: IE<9
// Handle iteration over inherited properties before own properties.
if ( support.ownLast ) {
for ( key in obj ) {
return hasOwn.call( obj, key );
}
}
// Own properties are enumerated firstly, so to speed up,
// if last one is own, then all properties are own.
for ( key in obj ) {}
return key === undefined || hasOwn.call( obj, key );
}
});

View File

@ -4,12 +4,12 @@ define([
"./css/var/cssExpand",
"./css/var/isHidden",
"./css/defaultDisplay",
"./core/swap",
"./css/support",
"./css/swap",
"./selector", // contains
"./support",
// Optional
"./offset"
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay ) {
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, support ) {
var getStyles, curCSS,
ralpha = /alpha\([^)]*\)/i,
@ -185,7 +185,7 @@ jQuery.extend({
// setting or getting the value
cssProps: {
// normalize float css property
"float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
"float": support.cssFloat ? "cssFloat" : "styleFloat"
},
// Get and set the style property on a DOM Node
@ -229,7 +229,7 @@ jQuery.extend({
// Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
// but it would mean to define eight (for every problematic property) identical functions
if ( !jQuery.support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
style[ name ] = "inherit";
}
@ -436,7 +436,7 @@ function getWidthOrHeight( elem, name, extra ) {
var valueIsBorderBox = true,
val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
styles = getStyles( elem ),
isBorderBox = jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
@ -455,7 +455,7 @@ function getWidthOrHeight( elem, name, extra ) {
// we need the check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox && ( jQuery.support.boxSizingReliable || val === elem.style[ name ] );
valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
// Normalize "", auto, and prepare for extra
val = parseFloat( val ) || 0;
@ -494,7 +494,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
elem,
name,
extra,
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles
) : 0
);
@ -502,7 +502,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
};
});
if ( !jQuery.support.opacity ) {
if ( !support.opacity ) {
jQuery.cssHooks.opacity = {
get: function( elem, computed ) {
// IE uses filters for opacity
@ -546,29 +546,58 @@ if ( !jQuery.support.opacity ) {
};
}
// These hooks cannot be added until DOM ready because the support test
// for it is not run until after DOM ready
jQuery(function() {
if ( !jQuery.support.reliableMarginRight ) {
jQuery.cssHooks.marginRight = {
get: function( elem, computed ) {
if ( computed ) {
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// Work around by temporarily setting element display to inline-block
return jQuery.swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}
jQuery.cssHooks.marginRight = {
get: function( elem, computed ) {
var reliableMarginRight = support.reliableMarginRight();
if ( reliableMarginRight == null ) {
// The test was not ready at this point; screw the hook this time
// but check again when needed next time.
return;
}
if ( reliableMarginRight ) {
// Hook not needed, remove it.
// Since there are no other hooks for marginRight, remove the whole object.
delete jQuery.cssHooks.marginRight;
return;
}
jQuery.cssHooks.marginRight.get = function ( elem, computed ) {
if ( computed ) {
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// Work around by temporarily setting element display to inline-block
return jQuery.swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] );
}
};
}
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right
// rather than make the css module depend on the offset module, we just check for it here
if ( !jQuery.support.pixelPosition && jQuery.fn.position ) {
jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = {
get: function( elem, computed ) {
return jQuery.cssHooks.marginRight.get( elem, computed );
}
};
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right
// rather than make the css module depend on the offset module, we just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = {
get: function( elem, computed ) {
var pixelPosition = support.pixelPosition();
if ( pixelPosition == null ) {
// The test was not ready at this point; screw the hook this time
// but check again when needed next time.
return;
}
if ( pixelPosition ) {
// Hook not needed, remove it.
// Since there are no other hooks for prop, remove the whole object.
delete jQuery.cssHooks[ prop ];
return;
}
jQuery.cssHooks[ prop ].get = function ( elem, computed ) {
if ( !support.pixelPosition() && jQuery.fn.position ) {
if ( computed ) {
computed = curCSS( elem, prop );
// if curCSS returns percentage, fallback to offset
@ -578,8 +607,10 @@ jQuery(function() {
}
}
};
});
}
return jQuery.cssHooks[ prop ].get( elem, computed );
}
};
});

View File

@ -1,14 +1,16 @@
define([
"../core",
"./support",
"../selector",
"../css"
], function( jQuery ) {
], function( jQuery, support ) {
jQuery.expr.filters.hidden = function( elem ) {
// Support: Opera <= 12.12
// Opera reports offsetWidths and offsetHeights less than zero on some elements
return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
(!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
(!support.reliableHiddenOffsets() &&
((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
};
jQuery.expr.filters.visible = function( elem ) {

192
src/css/support.js Normal file
View File

@ -0,0 +1,192 @@
define([
"../core",
"../var/support"
], function( jQuery, support ) {
(function () {
var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal,
pixelPositionVal, reliableMarginRightVal,
div = document.createElement( "div" ),
containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px",
divReset =
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
"display:block;padding:0;margin:0;border:0";
// Setup
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
a = div.getElementsByTagName( "a" )[ 0 ];
a.style.cssText = "float:left;opacity:.5";
// Make sure that element opacity exists
// (IE uses filter instead)
// Use a regex to work around a WebKit issue. See #5145
support.opacity = /^0.5/.test( a.style.opacity );
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support.cssFloat = !!a.style.cssFloat;
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
// Null elements to avoid leaks in IE.
a = div = null;
jQuery.extend(support, {
reliableHiddenOffsets: function() {
if ( reliableHiddenOffsetsVal != null ) {
return reliableHiddenOffsetsVal;
}
var container, tds, isSupported,
div = document.createElement( "div" ),
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
}
// Setup
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
container = document.createElement( "div" );
container.style.cssText = containerStyles;
body.appendChild( container ).appendChild( div );
// Support: IE8
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
tds = div.getElementsByTagName( "td" );
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
isSupported = ( tds[ 0 ].offsetHeight === 0 );
tds[ 0 ].style.display = "";
tds[ 1 ].style.display = "none";
// Support: IE8
// Check if empty table cells still have offsetWidth/Height
reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 );
// Null elements to avoid leaks in IE.
div = body = null;
return reliableHiddenOffsetsVal;
},
boxSizing: function() {
if ( boxSizingVal == null ) {
computeStyleTests();
}
return boxSizingVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
computeStyleTests();
}
return boxSizingReliableVal;
},
pixelPosition: function() {
if ( pixelPositionVal == null ) {
computeStyleTests();
}
return pixelPositionVal;
},
reliableMarginRight: function() {
var body, container, div, marginDiv;
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( reliableMarginRightVal == null && window.getComputedStyle ) {
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body ) {
// Test fired too early or in an unsupported environment, exit.
return;
}
container = document.createElement( "div" );
div = document.createElement( "div" );
container.style.cssText = containerStyles;
body.appendChild( container ).appendChild( div );
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
marginDiv = div.appendChild( document.createElement( "div" ) );
marginDiv.style.cssText = div.style.cssText = divReset;
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
reliableMarginRightVal =
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
body.removeChild( container );
}
return reliableMarginRightVal;
}
});
function computeStyleTests() {
var container, div,
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body ) {
// Test fired too early or in an unsupported environment, exit.
return;
}
container = document.createElement( "div" );
div = document.createElement( "div" );
container.style.cssText = containerStyles;
body.appendChild( container ).appendChild( div );
div.style.cssText =
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
"position:absolute;display:block;padding:1px;border:1px;width:4px;" +
"margin-top:1%;top:1%";
// 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() {
boxSizingVal = div.offsetWidth === 4;
});
// Will be changed later if needed.
boxSizingReliableVal = true;
pixelPositionVal = false;
reliableMarginRightVal = true;
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
boxSizingReliableVal =
( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
}
body.removeChild( container );
// Null elements to avoid leaks in IE.
div = body = null;
}
})();
return support;
});

View File

@ -3,8 +3,6 @@ define([
], function( jQuery ) {
// 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.
jQuery.swap = function( elem, options, callback, args ) {
var ret, name,
old = {};

View File

@ -1,8 +1,9 @@
define([
"./core",
"./var/deletedIds",
"./data/support",
"./data/accepts"
], function( jQuery, deletedIds ) {
], function( jQuery, deletedIds, support ) {
var rbrace = /(?:\{[\s\S]*\}|\[[\s\S]*\])$/,
rmultiDash = /([A-Z])/g;
@ -225,7 +226,7 @@ function internalRemoveData( elem, name, pvt ) {
// Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
/* jshint eqeqeq: false */
} else if ( jQuery.support.deleteExpando || cache != cache.window ) {
} else if ( support.deleteExpando || cache != cache.window ) {
/* jshint eqeqeq: true */
delete cache[ id ];

25
src/data/support.js Normal file
View File

@ -0,0 +1,25 @@
define([
"../var/support"
], function( support ) {
(function () {
var div = document.createElement( "div" );
// Execute the test only if not already executed in another module.
if (support.deleteExpando == null) {
// Support: IE<9
support.deleteExpando = true;
try {
delete div.test;
} catch( e ) {
support.deleteExpando = false;
}
}
// Null elements to avoid leaks in IE.
div = null;
})();
return support;
});

9
src/effects.js vendored
View File

@ -3,12 +3,14 @@ define([
"./var/pnum",
"./css/var/cssExpand",
"./css/var/isHidden",
"./css/defaultDisplay",
"./effects/support",
"./effects/Tween",
"./queue",
"./css",
"./deferred",
"./traversing"
], function( jQuery, pnum, cssExpand, isHidden, Tween ) {
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, support) {
var fxNow, timerId,
rfxtypes = /^(?:toggle|show|hide)$/,
@ -309,9 +311,8 @@ function defaultPrefilter( elem, props, opts ) {
// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
style.display = "inline-block";
} else {
style.zoom = 1;
}
@ -320,7 +321,7 @@ function defaultPrefilter( elem, props, opts ) {
if ( opts.overflow ) {
style.overflow = "hidden";
if ( !jQuery.support.shrinkWrapBlocks ) {
if ( !support.shrinkWrapBlocks() ) {
anim.always(function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];

76
src/effects/support.js Normal file
View File

@ -0,0 +1,76 @@
define([
"../var/strundefined",
"../var/support"
], function( strundefined, support ) {
(function () {
var a, shrinkWrapBlocksVal,
div = document.createElement( "div" ),
divReset =
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
"display:block;padding:0;margin:0;border:0";
// Setup
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
a = div.getElementsByTagName( "a" )[ 0 ];
a.style.cssText = "float:left;opacity:.5";
// Make sure that element opacity exists
// (IE uses filter instead)
// Use a regex to work around a WebKit issue. See #5145
support.opacity = /^0.5/.test( a.style.opacity );
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support.cssFloat = !!a.style.cssFloat;
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
// Null elements to avoid leaks in IE.
a = div = null;
support.shrinkWrapBlocks = function () {
var body, container, div, containerStyles;
if ( shrinkWrapBlocksVal == null ) {
body = document.getElementsByTagName( "body" )[ 0 ];
if ( !body ) {
// Test fired too early or in an unsupported environment, exit.
return;
}
containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px";
container = document.createElement( "div" );
div = document.createElement( "div" );
body.appendChild( container ).appendChild( div );
// Will be changed later if needed.
shrinkWrapBlocksVal = false;
if ( typeof div.style.zoom !== strundefined ) {
// Support: IE6
// Check if elements with layout shrink-wrap their children
div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1";
div.innerHTML = "<div></div>";
div.firstChild.style.width = "5px";
shrinkWrapBlocksVal = div.offsetWidth !== 3;
}
body.removeChild( container );
// Null elements to avoid leaks in IE.
body = container = div = null;
}
return shrinkWrapBlocksVal;
};
})();
return support;
});

View File

@ -4,10 +4,10 @@ define([
"./var/rnotwhite",
"./var/hasOwn",
"./var/slice",
"./event/support",
"./data/accepts",
"./selector",
"./support"
], function( jQuery, strundefined, rnotwhite, hasOwn, slice ) {
"./selector"
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support ) {
var rformElems = /^(?:input|select|textarea)$/i,
rkeyEvent = /^key/,
@ -772,7 +772,7 @@ jQuery.each({
});
// IE submit delegation
if ( !jQuery.support.submitBubbles ) {
if ( !support.submitBubbles ) {
jQuery.event.special.submit = {
setup: function() {
@ -819,7 +819,7 @@ if ( !jQuery.support.submitBubbles ) {
}
// IE change delegation and checkbox/radio fix
if ( !jQuery.support.changeBubbles ) {
if ( !support.changeBubbles ) {
jQuery.event.special.change = {
@ -878,7 +878,7 @@ if ( !jQuery.support.changeBubbles ) {
}
// Create "bubbling" focus and blur events
if ( !jQuery.support.focusinBubbles ) {
if ( !support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler while someone wants focusin/focusout

23
src/event/support.js Normal file
View File

@ -0,0 +1,23 @@
define([
"../var/support"
], function( support ) {
(function () {
var i, eventName,
div = document.createElement("div" );
// Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
for ( i in { submit: true, change: true, focusin: true }) {
div.setAttribute( eventName = "on" + i, "t" );
support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
}
// Null elements to avoid leaks in IE.
div = null;
})();
return support;
});

4
src/jquery.js vendored
View File

@ -16,7 +16,7 @@ define([
"./manipulation/_evalUrl",
"./wrap",
"./css",
"./css/hidden-visible-selectors",
"./css/hiddenVisibleSelectors",
"./serialize",
"./ajax",
"./ajax/xhr",
@ -24,7 +24,7 @@ define([
"./ajax/jsonp",
"./ajax/load",
"./effects",
"./effects/animated-selector",
"./effects/animatedSelector",
"./offset",
"./dimensions",
"./deprecated",

View File

@ -5,12 +5,12 @@ define([
"./var/deletedIds",
"./var/strundefined",
"./manipulation/var/rcheckableType",
"./manipulation/support",
"./data/accepts",
"./selector",
"./traversing",
"./event",
"./support"
], function( jQuery, concat, push, deletedIds, strundefined, rcheckableType ){
"./event"
], function( jQuery, concat, push, deletedIds, strundefined, rcheckableType, support ){
function createSafeFragment( document ) {
var list = nodeNames.split( "|" ),
@ -55,7 +55,7 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
_default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
_default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
},
safeFragment = createSafeFragment( document ),
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
@ -177,8 +177,8 @@ jQuery.fn.extend({
// See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( jQuery.support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
value = value.replace( rxhtmlTag, "<$1></$2>" );
@ -252,7 +252,7 @@ jQuery.fn.extend({
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
if ( isFunction || !( l <= 1 || typeof value !== "string" || support.checkClone || !rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
@ -398,7 +398,7 @@ function fixCloneNodeIssues( src, dest ) {
nodeName = dest.nodeName.toLowerCase();
// IE6-8 copies events bound via attachEvent when using cloneNode.
if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
data = jQuery._data( dest );
for ( e in data.events ) {
@ -425,7 +425,7 @@ function fixCloneNodeIssues( src, dest ) {
// element in IE9, the outerHTML strategy above is not sufficient.
// If the src has innerHTML and the destination does not,
// copy the src.innerHTML into the dest.innerHTML. #10324
if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
dest.innerHTML = src.innerHTML;
}
@ -514,7 +514,7 @@ jQuery.extend({
var destElements, node, clone, i, srcElements,
inPage = jQuery.contains( elem.ownerDocument, elem );
if ( jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
clone = elem.cloneNode( true );
// IE<=8 does not properly clone detached, unknown element nodes
@ -523,7 +523,7 @@ jQuery.extend({
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
}
if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
if ( (!support.noCloneEvent || !support.noCloneChecked) &&
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
@ -606,12 +606,12 @@ jQuery.extend({
}
// Manually add leading whitespace removed by IE
if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
}
// Remove IE's autoinserted <tbody> from table fragments
if ( !jQuery.support.tbody ) {
if ( !support.tbody ) {
// String was a <table>, *may* have spurious <tbody>
elem = tag === "table" && !rtbody.test( elem ) ?
@ -653,7 +653,7 @@ jQuery.extend({
// Reset defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
if ( !jQuery.support.appendChecked ) {
if ( !support.appendChecked ) {
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
}
@ -697,7 +697,7 @@ jQuery.extend({
i = 0,
internalKey = jQuery.expando,
cache = jQuery.cache,
deleteExpando = jQuery.support.deleteExpando,
deleteExpando = support.deleteExpando,
special = jQuery.event.special;
for ( ; (elem = elems[i]) != null; i++ ) {

View File

@ -0,0 +1,78 @@
define([
"../var/support"
], function( support ) {
(function () {
var input, fragment,
div = document.createElement("div");
// Setup
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
input = div.getElementsByTagName("input")[ 0 ];
input.type = "checkbox";
// IE strips leading whitespace when .innerHTML is used
support.leadingWhitespace = div.firstChild.nodeType === 3;
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
support.tbody = !div.getElementsByTagName( "tbody" ).length;
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
support.html5Clone =
document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
// Make sure checked status is properly cloned
input.checked = true;
support.noCloneChecked = input.cloneNode( true ).checked;
// #11217 - WebKit loses check when the name is after the checked attribute
input.setAttribute( "checked", "t" );
input.setAttribute( "name", "t" );
fragment = document.createDocumentFragment();
fragment.appendChild( input );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
support.appendChecked = input.checked;
// WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE<9
// Opera does not clone events (and typeof div.attachEvent === undefined).
// IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
support.noCloneEvent = true;
if ( div.attachEvent ) {
div.attachEvent( "onclick", function() {
support.noCloneEvent = false;
});
div.cloneNode( true ).click();
}
// Execute the test only if not already executed in another module.
if (support.deleteExpando == null) {
// Support: IE<9
support.deleteExpando = true;
try {
delete div.test;
} catch( e ) {
support.deleteExpando = false;
}
}
// Null elements to avoid leaks in IE.
input = fragment = div = null;
})();
return support;
});

View File

@ -1,255 +1,62 @@
define([
"./core",
"./var/strundefined",
"./core/swap",
"./var/support",
// This is listed as a dependency for build order, but it's still optional in builds
"./core/ready"
], function( jQuery, strundefined ) {
], function( jQuery, strundefined, support ) {
jQuery.support = (function( support ) {
// Note: most support tests are defined in their respective modules.
var all, a, input, select, fragment, opt, eventName, isSupported, i,
div = document.createElement("div");
jQuery(function() {
// We need to execute this one support test ASAP because we need to know
// if body.style.zoom needs to be set.
var container,
div = document.createElement( "div" ),
divReset =
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
"display:block;padding:0;margin:0;border:0",
body = document.getElementsByTagName("body")[0];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
}
// Setup
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
// Finish early in limited (non-browser) environments
all = div.getElementsByTagName("*") || [];
a = div.getElementsByTagName("a")[ 0 ];
if ( !a || !a.style || !all.length ) {
return support;
}
container = document.createElement( "div" );
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
// First batch of tests
select = document.createElement("select");
opt = select.appendChild( document.createElement("option") );
input = div.getElementsByTagName("input")[ 0 ];
body.appendChild( container ).appendChild( div );
a.style.cssText = "top:1px;float:left;opacity:.5";
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
support.getSetAttribute = div.className !== "t";
// IE strips leading whitespace when .innerHTML is used
support.leadingWhitespace = div.firstChild.nodeType === 3;
// Make sure that tbody elements aren't automatically inserted
// IE will insert them into empty tables
support.tbody = !div.getElementsByTagName("tbody").length;
// Make sure that link elements get serialized correctly by innerHTML
// This requires a wrapper element in IE
support.htmlSerialize = !!div.getElementsByTagName("link").length;
// Get the style information from getAttribute
// (IE uses .cssText instead)
support.style = /top/.test( a.getAttribute("style") );
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
support.hrefNormalized = a.getAttribute("href") === "/a";
// Make sure that element opacity exists
// (IE uses filter instead)
// Use a regex to work around a WebKit issue. See #5145
support.opacity = /^0.5/.test( a.style.opacity );
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support.cssFloat = !!a.style.cssFloat;
// Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
support.checkOn = !!input.value;
// Make sure that a selected-by-default option has a working selected property.
// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
support.optSelected = opt.selected;
// Tests for enctype support on a form (#6743)
support.enctype = !!document.createElement("form").enctype;
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
support.html5Clone = document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>";
// Will be defined later
// Will be changed later if needed.
support.inlineBlockNeedsLayout = false;
support.shrinkWrapBlocks = false;
support.pixelPosition = false;
support.deleteExpando = true;
support.noCloneEvent = true;
support.reliableMarginRight = true;
support.boxSizingReliable = true;
// Make sure checked status is properly cloned
input.checked = true;
support.noCloneChecked = input.cloneNode( true ).checked;
// Make sure that the options inside disabled selects aren't marked as disabled
// (WebKit marks them as disabled)
select.disabled = true;
support.optDisabled = !opt.disabled;
// Support: IE<9
try {
delete div.test;
} catch( e ) {
support.deleteExpando = false;
}
// Check if we can trust getAttribute("value")
input = document.createElement("input");
input.setAttribute( "value", "" );
support.input = input.getAttribute( "value" ) === "";
// Check if an input maintains its value after becoming a radio
input.value = "t";
input.setAttribute( "type", "radio" );
support.radioValue = input.value === "t";
// #11217 - WebKit loses check when the name is after the checked attribute
input.setAttribute( "checked", "t" );
input.setAttribute( "name", "t" );
fragment = document.createDocumentFragment();
fragment.appendChild( input );
// Check if a disconnected checkbox will retain its checked
// value of true after appended to the DOM (IE6/7)
support.appendChecked = input.checked;
// WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE<9
// Opera does not clone events (and typeof div.attachEvent === undefined).
// IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
if ( div.attachEvent ) {
div.attachEvent( "onclick", function() {
support.noCloneEvent = false;
});
div.cloneNode( true ).click();
}
// Support: IE<9 (lack submit/change bubble), Firefox 17+ (lack focusin event)
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
for ( i in { submit: true, change: true, focusin: true }) {
div.setAttribute( eventName = "on" + i, "t" );
support[ i + "Bubbles" ] = eventName in window || div.attributes[ eventName ].expando === false;
}
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
// Support: IE<9
// Iteration over object's inherited properties before its own.
for ( i in jQuery( support ) ) {
break;
}
support.ownLast = i !== "0";
// Run tests that need a body at doc ready
jQuery(function() {
var container, marginDiv, tds,
divReset = "padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",
body = document.getElementsByTagName("body")[0];
if ( !body ) {
// Return for frameset docs that don't have a body
return;
}
container = document.createElement("div");
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
body.appendChild( container ).appendChild( div );
// Support: IE8
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
tds = div.getElementsByTagName("td");
tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
isSupported = ( tds[ 0 ].offsetHeight === 0 );
tds[ 0 ].style.display = "";
tds[ 1 ].style.display = "none";
// Support: IE8
// Check if empty table cells still have offsetWidth/Height
support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
// Check box-sizing and margin behavior.
if ( typeof div.style.zoom !== strundefined ) {
// Support: IE<8
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
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%;";
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
// 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 ) {
support.pixelPosition = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
support.boxSizingReliable = ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
marginDiv = div.appendChild( document.createElement("div") );
marginDiv.style.cssText = div.style.cssText = divReset;
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
support.reliableMarginRight =
!parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
}
if ( typeof div.style.zoom !== strundefined ) {
if ( support.inlineBlockNeedsLayout ) {
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE from shrinking the body in IE 7 mode #12869
// Support: IE<8
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// them layout
div.innerHTML = "";
div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
// Support: IE6
// Check if elements with layout shrink-wrap their children
div.style.display = "block";
div.innerHTML = "<div></div>";
div.firstChild.style.width = "5px";
support.shrinkWrapBlocks = ( div.offsetWidth !== 3 );
if ( support.inlineBlockNeedsLayout ) {
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE from shrinking the body in IE 7 mode #12869
// Support: IE<8
body.style.zoom = 1;
}
body.style.zoom = 1;
}
}
body.removeChild( container );
// Null elements to avoid leaks in IE
container = div = tds = marginDiv = null;
});
body.removeChild( container );
// Null elements to avoid leaks in IE
all = select = fragment = opt = a = input = null;
return support;
})({});
container = div = null;
});
});

View File

@ -1,8 +1,7 @@
define([
"./core",
"./var/indexOf",
"./selector"
], function( jQuery, indexOf ) {
], function( jQuery ) {
var isSimple = /^.[^:#\[\.,]*$/,
rparentsprev = /^(?:parents|prev(?:Until|All))/,
rneedsContext = jQuery.expr.match.needsContext,

4
src/var/support.js Normal file
View File

@ -0,0 +1,4 @@
define(function() {
// All support tests are defined in their respective modules.
return {};
});

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
#test {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
width: 100px;
height: 100px;
padding: 10px;
}
</style>
</head>
<body>
<div id="test"></div>
<script src="../../jquery.js"></script>
<script>
var testWidth = jQuery( "#test" ).css( 'width' );
jQuery(function() {
window.parent.iframeCallback( testWidth );
});
</script>
</body>
</html>

View File

@ -18,10 +18,12 @@
<body>
<div>
<script src="../../jquery.js"></script>
<script src="getComputedSupport.js"></script>
</div>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery( "body" ).css( "backgroundColor" ), jQuery.support );
window.parent.iframeCallback( jQuery( "body" ).css( "backgroundColor" ),
getComputedSupport( jQuery.support ) );
});
</script>
</body>

View File

@ -12,7 +12,7 @@
<script src="../../jquery.js"></script>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.boxSizing );
window.parent.iframeCallback( jQuery.support.boxSizing() );
});
</script>
</body>

View File

@ -1,3 +1,3 @@
jQuery(function() {
parent.iframeCallback( jQuery.support );
parent.iframeCallback( getComputedSupport( jQuery.support ) );
});

View File

@ -15,6 +15,7 @@
<title>CSP Test Page</title>
<script src="../../jquery.js"></script>
<script src="csp.js"></script>
<script src="getComputedSupport.js"></script>
</head>
<body>
<p>CSP Test Page</p>

View File

@ -0,0 +1,14 @@
function getComputedSupport( support ) {
var prop,
result = {};
for ( prop in support ) {
if ( typeof support[ prop ] === "function" ) {
result[ prop ] = support[ prop ]();
} else {
result[ prop ] = support[ prop ];
}
}
return result;
}

View File

@ -16,7 +16,7 @@
</div>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks );
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks() );
});
</script>
</body>

View File

@ -836,6 +836,14 @@ test("css('width') and css('height') should respect box-sizing, see #11004", fun
equal( el_dis.css("height"), el_dis.css("height", el_dis.css("height")).css("height"), "css('height') is not respecting box-sizing for disconnected element, see #11004");
});
testIframeWithCallback( "css('width') should work correctly before document ready (#14084)",
"css/cssWidthBeforeDocReady.html",
function( cssWidthBeforeDocReady ) {
expect( 1 );
strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" );
}
);
test("certain css values of 'normal' should be convertable to a number, see #8627", function() {
expect ( 2 );

View File

@ -1078,7 +1078,7 @@ jQuery.each({
asyncTest("Effects chaining", function() {
var remaining = 16,
shrinkwrap = jQuery.support.shrinkWrapBlocks,
shrinkwrap = jQuery.support.shrinkWrapBlocks(),
props = [ "opacity", "height", "width", "display", "overflow" ],
setup = function( name, selector, hiddenOverflow ) {
var $el = jQuery( selector );

View File

@ -1,9 +1,26 @@
module("support", { teardown: moduleTeardown });
var computedSupport = getComputedSupport( jQuery.support );
function getComputedSupport( support ) {
var prop,
result = {};
for ( prop in support ) {
if ( typeof support[ prop ] === "function" ) {
result[ prop ] = support[ prop ]();
} else {
result[ prop ] = support[ prop ];
}
}
return result;
}
test( "zoom of doom (#13089)", function() {
expect( 1 );
if ( jQuery.support.inlineBlockNeedsLayout ) {
if ( computedSupport.inlineBlockNeedsLayout ) {
ok( document.body.style.zoom, "Added a zoom to the body (#11048, #12869)" );
} else {
ok( !document.body.style.zoom, "No zoom added to the body" );
@ -21,7 +38,7 @@ if ( jQuery.css ) {
stop();
// Run doc ready tests as well
jQuery(function() {
deepEqual( jQuery.extend( {}, support ), jQuery.support, "Same support properties" );
deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
start();
});
});
@ -29,7 +46,7 @@ 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" );
equal( boxSizing, computedSupport.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() {
@ -39,201 +56,208 @@ testIframeWithCallback( "A background on the testElement does not cause IE8 to c
testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlocks", "support/shrinkWrapBlocks.html", function( shrinkWrapBlocks ) {
expect( 1 );
strictEqual( shrinkWrapBlocks, jQuery.support.shrinkWrapBlocks, "jQuery.support.shrinkWrapBlocks properties are the same" );
strictEqual( shrinkWrapBlocks, computedSupport.shrinkWrapBlocks, "jQuery.support.shrinkWrapBlocks properties are the same" );
});
(function() {
var expected, version,
var expected,
userAgent = window.navigator.userAgent;
if ( /chrome/i.test( userAgent ) ) {
version = userAgent.match( /chrome\/(\d+)/i )[ 1 ];
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": true,
"optSelected": true,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": false,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": true,
"optDisabled": true,
"radioValue": true,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": true,
"clearCloneStyle": true,
"ownLast": false,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": true,
"pixelPosition": version >= 28
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": false,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": true,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": true,
"ownLast": false,
"pixelPosition": true,
"radioValue": true,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
} else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": true,
"optSelected": true,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": false,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": true,
"optDisabled": true,
"radioValue": false,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": true,
"clearCloneStyle": true,
"ownLast": false,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": true,
"pixelPosition": true
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": false,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": true,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": true,
"ownLast": false,
"pixelPosition": true,
"radioValue": false,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
} else if ( /msie 10\.0/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": true,
"optSelected": false,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": true,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": false,
"optDisabled": true,
"radioValue": false,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": true,
"clearCloneStyle": false,
"ownLast": false,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": false,
"pixelPosition": true
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
"cors": true,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": true,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": false,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": false,
"ownLast": false,
"pixelPosition": true,
"radioValue": false,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
} else if ( /msie 9\.0/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": true,
"optSelected": false,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": true,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": false,
"optDisabled": true,
"radioValue": false,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": false,
"clearCloneStyle": false,
"ownLast": false,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": false,
"pixelPosition": true
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
"cors": false,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": true,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": false,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": false,
"ownLast": false,
"pixelPosition": true,
"radioValue": false,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
} else if ( /msie 8\.0/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": false,
"tbody": true,
"htmlSerialize": false,
"style": false,
"hrefNormalized": true,
"opacity": false,
"cssFloat": false,
"checkOn": true,
"optSelected": false,
"getSetAttribute": true,
"enctype": true,
"html5Clone": false,
"submitBubbles": false,
"changeBubbles": false,
"focusinBubbles": true,
"deleteExpando": false,
"noCloneEvent": false,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": false,
"optDisabled": true,
"radioValue": false,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": false,
"ajax": true,
"cors": false,
"clearCloneStyle": true,
"ownLast": true,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": true,
"pixelPosition": false
"changeBubbles": false,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": false,
"cssFloat": false,
"deleteExpando": false,
"enctype": true,
"focusinBubbles": true,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": false,
"htmlSerialize": false,
"inlineBlockNeedsLayout": false,
"input": false,
"leadingWhitespace": false,
"noCloneChecked": false,
"noCloneEvent": false,
"opacity": false,
"optDisabled": true,
"optSelected": false,
"ownLast": true,
"pixelPosition": false,
"radioValue": false,
"reliableHiddenOffsets": false,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": false,
"submitBubbles": false,
"tbody": true
};
} else if ( /msie 7\.0/i.test( userAgent ) ) {
expected = {
"ajax": true,
"appendChecked": false,
"boxSizing": false,
"boxSizingReliable": true,
"changeBubbles": false,
"checkClone": false,
"checkOn": true,
"clearCloneStyle": true,
"cors": false,
"cssFloat": false,
"deleteExpando": false,
@ -244,143 +268,152 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"html5Clone": false,
"htmlSerialize": false,
"inlineBlockNeedsLayout": true,
"input": false,
"leadingWhitespace": false,
"noCloneChecked": false,
"noCloneEvent": false,
"opacity": false,
"optDisabled": true,
"optSelected": false,
"ownLast": true,
"pixelPosition": false,
"radioValue": false,
"reliableHiddenOffsets": false,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"submitBubbles": false,
"tbody": false,
"style": false,
"clearCloneStyle": true,
"ownLast": true,
"boxSizing": false,
"boxSizingReliable": true,
"pixelPosition": false
"submitBubbles": false,
"tbody": false
};
} else if ( /msie 6\.0/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": false,
"tbody": false,
"htmlSerialize": false,
"style": false,
"hrefNormalized": false,
"opacity": false,
"cssFloat": false,
"checkOn": true,
"optSelected": false,
"getSetAttribute": false,
"enctype": true,
"html5Clone": false,
"submitBubbles": false,
"changeBubbles": false,
"focusinBubbles": true,
"deleteExpando": false,
"noCloneEvent": false,
"inlineBlockNeedsLayout": true,
"shrinkWrapBlocks": true,
"reliableMarginRight": true,
"noCloneChecked": false,
"optDisabled": true,
"radioValue": false,
"checkClone": false,
"appendChecked": false,
"reliableHiddenOffsets": false,
"ajax": true,
"cors": false,
"clearCloneStyle": true,
"ownLast": true,
"appendChecked": false,
"boxSizing": false,
"boxSizingReliable": true,
"pixelPosition": false
};
} else if ( /5\.1\.1 safari/i.test( userAgent ) ) {
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": false,
"optSelected": true,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": false,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": true,
"optDisabled": true,
"radioValue": true,
"changeBubbles": false,
"checkClone": false,
"appendChecked": false,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": true,
"checkOn": true,
"clearCloneStyle": true,
"ownLast": false,
"cors": false,
"cssFloat": false,
"deleteExpando": false,
"enctype": true,
"focusinBubbles": true,
"getSetAttribute": false,
"hrefNormalized": false,
"html5Clone": false,
"htmlSerialize": false,
"inlineBlockNeedsLayout": true,
"input": false,
"leadingWhitespace": false,
"noCloneChecked": false,
"noCloneEvent": false,
"opacity": false,
"optDisabled": true,
"optSelected": false,
"ownLast": true,
"pixelPosition": false,
"radioValue": false,
"reliableHiddenOffsets": false,
"reliableMarginRight": true,
"shrinkWrapBlocks": true,
"style": false,
"submitBubbles": false,
"tbody": false
};
} else if ( /6\.0\.\d+ safari/i.test( userAgent ) ) {
expected = {
"ajax": true,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": true,
"pixelPosition": false
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": false,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": true,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": true,
"ownLast": false,
"pixelPosition": false,
"radioValue": true,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
} else if ( /firefox/i.test( userAgent ) ) {
version = userAgent.match( /firefox\/(\d+)/i )[ 1 ];
expected = {
"leadingWhitespace": true,
"tbody": true,
"htmlSerialize": true,
"style": true,
"hrefNormalized": true,
"opacity": true,
"cssFloat": true,
"checkOn": true,
"optSelected": true,
"getSetAttribute": true,
"enctype": true,
"html5Clone": true,
"submitBubbles": true,
"changeBubbles": true,
"focusinBubbles": false,
"deleteExpando": true,
"noCloneEvent": true,
"inlineBlockNeedsLayout": false,
"shrinkWrapBlocks": false,
"reliableMarginRight": true,
"noCloneChecked": true,
"optDisabled": true,
"radioValue": true,
"checkClone": true,
"appendChecked": true,
"reliableHiddenOffsets": true,
"ajax": true,
"cors": true,
"clearCloneStyle": true,
"ownLast": false,
"appendChecked": true,
"boxSizing": true,
"boxSizingReliable": version >= 23,
"pixelPosition": true
"boxSizingReliable": true,
"changeBubbles": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"cssFloat": true,
"deleteExpando": true,
"enctype": true,
"focusinBubbles": false,
"getSetAttribute": true,
"hrefNormalized": true,
"html5Clone": true,
"htmlSerialize": true,
"inlineBlockNeedsLayout": false,
"input": true,
"leadingWhitespace": true,
"noCloneChecked": true,
"noCloneEvent": true,
"opacity": true,
"optDisabled": true,
"optSelected": true,
"ownLast": false,
"pixelPosition": true,
"radioValue": true,
"reliableHiddenOffsets": true,
"reliableMarginRight": true,
"shrinkWrapBlocks": false,
"style": true,
"submitBubbles": true,
"tbody": true
};
}
if ( expected ) {
test( "Verify that the support tests resolve as expected per browser", function() {
expect( 33 );
var i, prop,
j = 0;
for ( var i in expected ) {
for ( prop in computedSupport ) {
j++;
}
expect( j );
for ( i in expected ) {
if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) {
equal( jQuery.support[i], expected[i], "jQuery.support['" + i + "']: " + jQuery.support[i] + ", expected['" + i + "']: " + expected[i]);
equal( computedSupport[i], expected[i],
"jQuery.support['" + i + "']: " + computedSupport[i] +
", expected['" + i + "']: " + expected[i]);
} else {
ok( true, "no ajax; skipping jQuery.support['" + i + "']" );
}
@ -390,13 +423,10 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
})();
// Support: Safari 5.1
// Shameless browser-sniff, but Safari 5.1 mishandles CSP
if ( !( typeof navigator !== "undefined" &&
(/ AppleWebKit\/\d.*? Version\/(\d+)/.exec(navigator.userAgent) || [])[1] < 6 ) ) {
testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions", "support/csp.php", function( support ) {
testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions",
"support/csp.php",
function( support ) {
expect( 1 );
deepEqual( jQuery.extend( {}, support ), jQuery.support, "No violations of CSP polices" );
});
}
deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" );
}
);