Skip to content
Permalink
Browse files

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

…ponents.
  • Loading branch information...
mgol committed Sep 2, 2013
1 parent 9035cab commit badcd1b6f301e6253405f17759c1270549a34e12
@@ -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.

@@ -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;

@@ -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
@@ -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";
}

@@ -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;

});
@@ -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
@@ -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 );
}
});

0 comments on commit badcd1b

Please sign in to comment.
You can’t perform that action at this time.