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

This commit is contained in:
Michał Gołębiowski 2013-08-27 00:54:13 +02:00
parent 776012b8b3
commit bbbdd94725
35 changed files with 383 additions and 433 deletions

View File

@ -42,7 +42,7 @@ module.exports = function( grunt ) {
ajax: [ "manipulation/_evalUrl" ],
callbacks: [ "deferred" ],
css: [ "effects", "dimensions", "offset" ],
sizzle: [ "css/hidden-visible-selectors", "effects/animated-selector" ]
sizzle: [ "css/hiddenVisibleSelectors", "effects/animatedSelector" ]
}
}
},

View File

@ -88,13 +88,12 @@ 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.
As a special case, you may also replace Sizzle by using a special flag `grunt custom:-sizzle`.
- **sizzle**: The Sizzle selector engine. When this module is excluded, it is replaced by a rudimentary selector engine based on the browser's `querySelectorAll` method that does not support jQuery selector extensions or enhanced semantics. See the selector-native.js file for details.
*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 ) {
jQuery.ajaxSettings.xhr = function() {
try {
@ -33,13 +33,13 @@ if ( window.ActiveXObject ) {
});
}
jQuery.support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
jQuery.support.ajax = xhrSupported = !!xhrSupported;
support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
support.ajax = xhrSupported = !!xhrSupported;
jQuery.ajaxTransport(function( options ) {
var callback;
// Cross domain only allowed if supported through XMLHttpRequest
if ( jQuery.support.cors || xhrSupported && !options.crossDomain ) {
if ( support.cors || xhrSupported && !options.crossDomain ) {
return {
send: function( headers, complete ) {
var i, id,

View File

@ -2,9 +2,9 @@ define([
"../core",
"../var/rnotwhite",
"../var/strundefined",
"../selector",
"../support"
], function( jQuery, rnotwhite, strundefined ) {
"./support",
"../selector"
], function( jQuery, rnotwhite, strundefined, support ) {
var nodeHook, boolHook,
attrHandle = jQuery.expr.attrHandle;
@ -93,7 +93,8 @@ 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;

View File

@ -1,7 +1,7 @@
define([
"../core",
"../support"
], function( jQuery ) {
"./support"
], function( jQuery, support ) {
var rfocusable = /^(?:input|select|textarea|button)$/i;
@ -65,7 +65,7 @@ jQuery.extend({
// Support: IE9+
// Selectedness for an option in an optgroup can be inaccurate
if ( !jQuery.support.optSelected ) {
if ( !support.optSelected ) {
jQuery.propHooks.selected = {
get: function( elem ) {
var parent = elem.parentNode;

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

@ -0,0 +1,35 @@
define([
"../var/support"
], function( support ) {
(function () {
var input = document.createElement( "input" ),
select = document.createElement( "select" ),
opt = select.appendChild( document.createElement( "option" ) );
input.type = "checkbox";
// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
// Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
support.checkOn = input.value !== "";
// Must access the parent to make an option select properly
// Support: IE9, IE10
support.optSelected = opt.selected;
// 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 an input maintains its value after becoming a radio
// Support: IE9, IE10
input = document.createElement( "input" );
input.value = "t";
input.type = "radio";
support.radioValue = input.value === "t";
})();
return support;
});

View File

@ -1,7 +1,7 @@
define([
"../core",
"../support"
], function( jQuery ) {
"./support"
], function( jQuery, support ) {
var rreturn = /\r/g;
@ -95,7 +95,7 @@ jQuery.extend({
// IE6-9 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
@ -146,7 +146,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,9 +9,10 @@ define([
"./var/class2type",
"./var/toString",
"./var/hasOwn",
"./var/trim"
"./var/trim",
"./var/support"
], function( strundefined, arr, slice, concat, push, indexOf,
class2type, toString, hasOwn, trim ) {
class2type, toString, hasOwn, trim, support ) {
var
// A central reference to the root jQuery(document)
@ -702,7 +703,11 @@ jQuery.extend({
length ? fn( elems[0], key ) : emptyGet;
},
now: Date.now
now: Date.now,
// jQuery.support is not used in Core but other projects attach their
// properties to it so it needs to exist.
support: support
});
// Populate the class2type map

View File

@ -3,15 +3,15 @@ define([
"./var/pnum",
"./css/var/cssExpand",
"./css/var/isHidden",
"./css/support",
"./css/defaultDisplay",
"./data/var/data_priv",
"./core/swap",
"./css/swap",
"./core/ready",
"./selector", // contains
"./support",
// Optional
"./offset"
], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) {
], function( jQuery, pnum, cssExpand, isHidden, support, defaultDisplay, data_priv ) {
var curCSS,
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
@ -233,7 +233,7 @@ jQuery.extend({
// Fixes #8908, it can be done more correctly by specifying 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";
}
@ -382,7 +382,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 = 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
@ -401,7 +401,8 @@ 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;
@ -440,7 +441,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
elem,
name,
extra,
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
styles
) : 0
);
@ -448,42 +449,49 @@ jQuery.each([ "height", "width" ], function( i, name ) {
};
});
// These hooks cannot be added until DOM ready because the support test
// for it is not run until after DOM ready
jQuery(function() {
// Support: Android 2.3
if ( !jQuery.support.reliableMarginRight ) {
jQuery.cssHooks.marginRight = {
get: function( elem, computed ) {
if ( computed ) {
// Support: Android 2.3
// 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" ] );
}
}
};
// Support: Android 2.3
jQuery.cssHooks.marginRight = {
get: function( elem, computed ) {
if ( support.reliableMarginRight() ) {
// Hook not needed, remove it.
// Since there are no other hooks for marginRight, remove the whole object.
delete jQuery.cssHooks.marginRight;
return;
}
if ( computed ) {
// Support: Android 2.3
// 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 ) {
if ( computed ) {
computed = curCSS( elem, prop );
// if curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" :
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 ) {
if ( support.pixelPosition() || !jQuery.fn.position ) {
// 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 ( i, prop ) {
if ( computed ) {
computed = curCSS( elem, prop );
// if curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" :
computed;
}
};
});
}
return jQuery.cssHooks[ prop ].get( i, prop );
}
};
});
// These hooks are used by animate to expand properties

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

@ -0,0 +1,82 @@
define([
"../var/support"
], function( support ) {
(function () {
var pixelPositionVal, boxSizingReliableVal,
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
"-moz-box-sizing:content-box;box-sizing:content-box",
docElem = document.documentElement,
container = document.createElement( "div" ),
div = document.createElement( "div" );
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" +
"margin-top:1px";
container.appendChild( div );
// Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation.
function computePixelPositionAndBoxSizingReliable() {
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
"box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" +
"position:absolute;top:1%";
docElem.appendChild( container );
var divStyle = window.getComputedStyle( div, null );
pixelPositionVal = divStyle.top !== "1%";
boxSizingReliableVal = divStyle.width === "4px";
docElem.removeChild( container );
}
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
jQuery.extend(support, {
pixelPosition: function() {
// This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though.
computePixelPositionAndBoxSizingReliable();
return pixelPositionVal;
},
boxSizingReliable: function() {
if ( boxSizingReliableVal == null ) {
computePixelPositionAndBoxSizingReliable();
}
return boxSizingReliableVal;
},
reliableMarginRight: function() {
// Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// This support function is only executed once so no memoizing is needed.
var ret,
marginDiv = div.appendChild( document.createElement( "div" ) );
marginDiv.style.cssText = div.style.cssText = divReset;
marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px";
docElem.appendChild( container );
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
docElem.removeChild( container );
// Clean up the div for other support tests.
div.innerHTML = "";
return ret;
}
});
}
})();
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

@ -4,11 +4,11 @@ define([
"./var/rnotwhite",
"./var/hasOwn",
"./var/slice",
"./event/support",
"./data/var/data_priv",
"./data/accepts",
"./selector",
"./support"
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, data_priv ) {
"./selector"
], function( jQuery, strundefined, rnotwhite, hasOwn, slice, support, data_priv ) {
var rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/,
@ -716,7 +716,8 @@ jQuery.each({
// Create "bubbling" focus and blur events
// Support: Firefox, Chrome, Safari
if ( !jQuery.support.focusinBubbles ) {
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
if ( !support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler while someone wants focusin/focusout

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

@ -0,0 +1,9 @@
define([
"../var/support"
], function( support ) {
support.focusinBubbles = "onfocusin" in window;
return support;
});

5
src/jquery.js vendored
View File

@ -5,7 +5,6 @@ define([
"./callbacks",
"./deferred",
"./core/ready",
"./support",
"./data",
"./queue",
"./queue/delay",
@ -16,7 +15,7 @@ define([
"./manipulation/_evalUrl",
"./wrap",
"./css",
"./css/hidden-visible-selectors",
"./css/hiddenVisibleSelectors",
"./serialize",
"./ajax",
"./ajax/xhr",
@ -24,7 +23,7 @@ define([
"./ajax/jsonp",
"./ajax/load",
"./effects",
"./effects/animated-selector",
"./effects/animatedSelector",
"./offset",
"./dimensions",
"./deprecated",

View File

@ -3,14 +3,14 @@ define([
"./var/concat",
"./var/push",
"./manipulation/var/rcheckableType",
"./manipulation/support",
"./data/var/data_priv",
"./data/var/data_user",
"./data/accepts",
"./selector",
"./traversing",
"./event",
"./support"
], function( jQuery, concat, push, rcheckableType, data_priv, data_user ){
"./event"
], function( jQuery, concat, push, rcheckableType, support, data_priv, data_user ){
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
rtagName = /<([\w:]+)/,
@ -218,7 +218,8 @@ 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 ) {
@ -324,7 +325,8 @@ jQuery.extend({
// Support: IE >= 9
// Fix Cloning issues
if ( !jQuery.support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
if ( !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
destElements = getAll( clone );

View File

@ -0,0 +1,29 @@
define([
"../var/support"
], function( support ){
(function () {
var input = document.createElement( "input" ),
fragment = document.createDocumentFragment();
input.type = "checkbox";
// Make sure checked status is properly cloned
// Support: IE9, IE10
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.appendChild( input );
// Support: Safari 5.1, Android 4.x, Android 2.3
// old WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
})();
return support;
});

View File

@ -1,111 +0,0 @@
define([
"./core",
"./core/swap",
// This is listed as a dependency for build order, but it's still optional in builds
"./core/ready"
], function( jQuery ) {
jQuery.support = (function( support ) {
var container, marginDiv, divStyle,
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",
docElem = document.documentElement,
input = document.createElement("input"),
fragment = document.createDocumentFragment(),
div = document.createElement("div"),
select = document.createElement("select"),
opt = select.appendChild( document.createElement("option") );
// Finish early in limited environments
if ( !input.type ) {
return support;
}
input.type = "checkbox";
// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
// Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
support.checkOn = input.value !== "";
// Must access the parent to make an option select properly
// Support: IE9, IE10
support.optSelected = opt.selected;
// This is hard-coded to true for compatibility reasons,
// all supported browsers passed the test.
support.boxSizing = true;
// Will be defined later
support.reliableMarginRight = true;
support.boxSizingReliable = true;
support.pixelPosition = false;
// Make sure checked status is properly cloned
// Support: IE9, IE10
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;
// Check if an input maintains its value after becoming a radio
// Support: IE9, IE10
input = document.createElement("input");
input.value = "t";
input.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.appendChild( input );
// Support: Safari 5.1, Android 4.x, Android 2.3
// old WebKit doesn't clone checked state correctly in fragments
support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: Firefox, Chrome, Safari
// Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
support.focusinBubbles = "onfocusin" in window;
div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box";
container = document.createElement("div");
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
// Check box-sizing and margin behavior.
docElem.appendChild( container ).appendChild( div );
div.innerHTML = "";
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%";
// Use window.getComputedStyle because jsdom on node.js will break without it.
if ( window.getComputedStyle ) {
divStyle = window.getComputedStyle( div, null );
support.pixelPosition = ( divStyle || {} ).top !== "1%";
support.boxSizingReliable = ( divStyle || { width: "4px" } ).width === "4px";
// Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// 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 );
}
docElem.removeChild( container );
return support;
})( {} );
});

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

@ -17,10 +17,7 @@
<div id="test"></div>
<script src="../../jquery.js"></script>
<script>
var testWidth = jQuery( "#test" ).css( 'width' );
jQuery(function() {
window.parent.iframeCallback( testWidth );
});
window.parent.iframeCallback( jQuery( "#test" ).css( 'width' ) );
</script>
</body>
</html>

View File

@ -1,21 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
html {
/**
* we need to null out border-width, because it causes bug #3838
* and until we drop IE6, this test will fail in IE6 if we didn't
* special case this situation.
**/
border-width: 0;
}
</style>
</head>
<body>
<div>
<script src="../../jquery.js"></script>
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -18,11 +18,11 @@
<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>
</html>

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
zoom: 0.87;
}
</style>
</head>
<body>
<script src="../../jquery.js"></script>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.boxSizing );
});
</script>
</body>
</html>

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

@ -1,23 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr" id="html">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
</style>
</head>
<body>
<div>
<script src="../../jquery.js"></script>
</div>
<script>
jQuery(function() {
window.parent.iframeCallback( jQuery.support.shrinkWrapBlocks );
});
</script>
</body>
</html>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body {
background: url('../1x1.jpg');
}
</style>
<script src="../../jquery.js"></script>
</head>
<body>
<script>
window.parent.iframeCallback();
</script>
</body>
</html>

View File

@ -1,7 +1,6 @@
/* for testing opacity set in styles in IE */
ol#empty {
opacity: 0;
filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff');
}
div#fx-tests h4 {
@ -35,7 +34,7 @@ div.autowidth {
}
div.autoopacity {
opacity: auto;
opacity: 1;
}
div.largewidth {
@ -46,10 +45,6 @@ div.largeheight {
height: 100px;
}
div.largeopacity {
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=100);
}
div.medwidth {
width: 50px;
}
@ -60,7 +55,6 @@ div.medheight {
div.medopacity {
opacity: 0.5;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);
}
div.nowidth {
@ -73,7 +67,6 @@ div.noheight {
div.noopacity {
opacity: 0;
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);
}
div.hidden {
@ -132,9 +125,6 @@ div#show-tests * { display: none; }
#nothiddendivchild.em { font-size: 2em; }
#nothiddendivchild.prct { font-size: 150%; }
/* For testing type on vml in IE #7071 */
v\:oval { behavior:url(#default#VML); display:inline-block; }
/* 8099 changes to default styles are read correctly */
tt { display: none; }
sup { display: none; }
@ -143,9 +133,6 @@ dfn { display: none; }
/* #9239 Attach a background to the body( avoid crashes in removing the test element in support ) */
body, div { background: url(http://static.jquery.com/files/rocker/images/logo_jquery_215x53.gif) no-repeat -1000px 0; }
/* #6652 REMOVE FILTER:ALPHA(OPACITY=100) AFTER ANIMATION */
#t6652 div { filter: alpha(opacity=50); }
/* #10501 */
section { background:#f0f; display:block; }

View File

@ -797,10 +797,13 @@ 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 works correctly before document ready", "css/cssWidthBeforeDocReady.html", function( cssWidthBeforeDocReady ) {
expect( 1 );
strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" );
});
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

@ -448,21 +448,6 @@ test("setters with and without box-sizing:border-box", function(){
equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" );
});
testIframe( "dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) {
// this test is practically tautological, but there is a bug in IE8
// with no simple workaround, so this test exposes the bug and works around it
if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) {
expect( 2 );
equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" );
equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" );
} else {
// all tests should have at least one assertion
expect( 1 );
ok( true, "skipping test (conditions not satisfied)" );
}
});
testIframe( "dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) {
expect(2);

View File

@ -1796,15 +1796,9 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() {
// First clone
$clone = $section.clone();
// Infer that the test is being run in IE<=8
if ( $clone[ 0 ].outerHTML && !jQuery.support.opacity ) {
// This branch tests cloning nodes by reading the outerHTML, used only in IE<=8
equal( $clone[ 0 ].outerHTML, "<section></section>", "detached clone outerHTML matches '<section></section>'" );
} else {
// This branch tests a known behaviour in modern browsers that should never fail.
// Included for expected test count symmetry (expecting 1)
equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" );
}
// This branch tests a known behaviour in modern browsers that should never fail.
// Included for expected test count symmetry (expecting 1)
equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION'" );
// Bind an event
$section.on( "click", function() {

View File

@ -1,5 +1,22 @@
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;
}
if ( jQuery.css ) {
testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) {
expect( 2 );
@ -9,137 +26,109 @@ if ( jQuery.css ) {
};
ok( okValue[ color ], "color was not reset (" + color + ")" );
stop();
// Run doc ready tests as well
jQuery(function() {
deepEqual( jQuery.extend( {}, support ), jQuery.support, "Same support properties" );
start();
});
deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" );
});
}
testIframeWithCallback( "A non-1 zoom on body doesn't cause WebKit to fail box-sizing test", "support/boxSizing.html", function( boxSizing ) {
expect( 1 );
equal( boxSizing, jQuery.support.boxSizing, "box-sizing properly detected on page with non-1 body zoom" );
});
testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash.html", function() {
expect( 1 );
ok( true, "IE8 does not crash" );
});
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" );
});
(function() {
var expected, version,
var expected,
userAgent = window.navigator.userAgent;
if ( /chrome/i.test( userAgent ) ) {
version = userAgent.match( /chrome\/(\d+)/i )[ 1 ];
expected = {
"checkOn":true,
"optSelected":true,
"optDisabled":true,
"focusinBubbles":false,
"reliableMarginRight":true,
"noCloneChecked":true,
"radioValue":true,
"checkClone":true,
"ajax":true,
"cors":true,
"clearCloneStyle": true,
"boxSizing": true,
"ajax": true,
"boxSizingReliable": true,
"pixelPosition": version >= 28
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"focusinBubbles": false,
"noCloneChecked": true,
"optDisabled": true,
"optSelected": true,
"pixelPosition": true,
"radioValue": true,
"reliableMarginRight": true
};
} else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
expected = {
"checkOn":true,
"optSelected":true,
"optDisabled":true,
"focusinBubbles":false,
"reliableMarginRight":true,
"noCloneChecked":true,
"radioValue":false,
"checkClone":true,
"ajax":true,
"cors":true,
"clearCloneStyle": true,
"boxSizing": true,
"ajax": true,
"boxSizingReliable": true,
"pixelPosition": true
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"focusinBubbles": false,
"noCloneChecked": true,
"optDisabled": true,
"optSelected": true,
"pixelPosition": true,
"radioValue": false,
"reliableMarginRight": true
};
} else if ( /msie 10\.0/i.test( userAgent ) ) {
expected = {
"checkOn":true,
"optSelected":false,
"optDisabled":true,
"focusinBubbles":true,
"reliableMarginRight":true,
"noCloneChecked":false,
"radioValue":false,
"checkClone":true,
"ajax":true,
"cors":true,
"clearCloneStyle": false,
"boxSizing": true,
"ajax": true,
"boxSizingReliable": false,
"pixelPosition": true
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
"cors": true,
"focusinBubbles": true,
"noCloneChecked": false,
"optDisabled": true,
"optSelected": false,
"pixelPosition": true,
"radioValue": false,
"reliableMarginRight": true
};
} else if ( /msie 9\.0/i.test( userAgent ) ) {
expected = {
"checkOn":true,
"optSelected":false,
"optDisabled":true,
"focusinBubbles":true,
"reliableMarginRight":true,
"noCloneChecked":false,
"radioValue":false,
"checkClone":true,
"ajax":true,
"cors":false,
"clearCloneStyle": false,
"boxSizing": true,
"ajax": true,
"boxSizingReliable": false,
"pixelPosition": true
"checkClone": true,
"checkOn": true,
"clearCloneStyle": false,
"cors": false,
"focusinBubbles": true,
"noCloneChecked": false,
"optDisabled": true,
"optSelected": false,
"pixelPosition": true,
"radioValue": false,
"reliableMarginRight": true
};
} else if ( /5\.1\.\d+ safari/i.test( userAgent ) ) {
} else if ( /6\.0\.\d+ safari/i.test( userAgent ) ) {
expected = {
"checkOn":false,
"optSelected":true,
"optDisabled":true,
"focusinBubbles":false,
"reliableMarginRight":true,
"noCloneChecked":true,
"radioValue":true,
"checkClone":false,
"ajax":true,
"cors":true,
"clearCloneStyle": true,
"boxSizing": true,
"ajax": true,
"boxSizingReliable": true,
"pixelPosition": false
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"cors": true,
"focusinBubbles": false,
"noCloneChecked": true,
"optDisabled": true,
"optSelected": true,
"pixelPosition": false,
"radioValue": true,
"reliableMarginRight": true
};
} else if ( /firefox/i.test( userAgent ) ) {
version = userAgent.match( /firefox\/(\d+)/i )[ 1 ];
expected = {
"checkOn":true,
"optSelected":true,
"optDisabled":true,
"focusinBubbles":false,
"reliableMarginRight":true,
"noCloneChecked":true,
"radioValue":true,
"checkClone":true,
"ajax":true,
"cors":true,
"ajax": true,
"boxSizingReliable": true,
"checkClone": true,
"checkOn": true,
"clearCloneStyle": true,
"boxSizing": true,
"boxSizingReliable": version >= 23,
"pixelPosition": true
"cors": true,
"focusinBubbles": false,
"noCloneChecked": true,
"optDisabled": true,
"optSelected": true,
"pixelPosition": true,
"radioValue": true,
"reliableMarginRight": true
};
}
@ -148,17 +137,20 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
var i, prop,
j = 0;
for ( prop in jQuery.support ) {
for ( prop in computedSupport ) {
j++;
}
expect( j );
for ( i in expected ) {
// TODO check for all modules containing support properties
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 + "']" );
ok( true, "no ajax; skipping jQuery.support[' " + i + " ']" );
}
}
});
@ -166,13 +158,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" );
}
);