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

parent 9035cab8
......@@ -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
......@@ -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.
......
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;
......
......@@ -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
......
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";
}
......
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;
});
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
......
......@@ -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 );
}
});
......
......@@ -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" ] );
}
};
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;
}
// 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 ) {
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 );
}
};
});
......
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 ) {
......
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;
});
......@@ -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 = {};
......
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 ];
......
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;
});
......@@ -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 ];
......
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;
});
......@@ -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
......
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;
});
......@@ -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",
......
......@@ -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++ ) {
......
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;
});
This diff is collapsed.
define([
"./core",
"./var/indexOf",
"./selector"
], function( jQuery, indexOf ) {
], function( jQuery ) {
var isSimple = /^.[^:#\[\.,]*$/,
rparentsprev = /^(?:parents|prev(?:Until|All))/,
rneedsContext = jQuery.expr.match.needsContext,
......
define(function() {
// All support tests are defined in their respective modules.
return {};
});
<!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>
......@@ -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>
......
......@@ -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>
......
jQuery(function() {
parent.iframeCallback( jQuery.support );
parent.iframeCallback( getComputedSupport( jQuery.support ) );
});
......@@ -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>
......
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;
}
......@@ -16,7 +16,7 @@
</div>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks );
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks() );
});
</script>
</body>
......
......@@ -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 );
......
......@@ -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 );
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment