aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2013-09-02 19:21:09 +0200
committerMichał Gołębiowski <m.goleb@gmail.com>2013-09-06 03:40:49 +0200
commitbadcd1b6f301e6253405f17759c1270549a34e12 (patch)
tree85c41bdda0cfcfa7a12b3a4d5bb5022e6a06684d /src
parent9035cab8c8574404c9eaeb795d0d87f4df772d45 (diff)
downloadjquery-badcd1b6f301e6253405f17759c1270549a34e12.tar.gz
jquery-badcd1b6f301e6253405f17759c1270549a34e12.zip
Fix #10814. Fix #14084. Make support tests lazy and broken out to components.
Diffstat (limited to 'src')
-rw-r--r--src/ajax/xhr.js12
-rw-r--r--src/attributes/attr.js14
-rw-r--r--src/attributes/prop.js10
-rw-r--r--src/attributes/support.js63
-rw-r--r--src/attributes/val.js8
-rw-r--r--src/core.js98
-rw-r--r--src/css.js91
-rw-r--r--src/css/hiddenVisibleSelectors.js (renamed from src/css/hidden-visible-selectors.js)6
-rw-r--r--src/css/support.js192
-rw-r--r--src/css/swap.js (renamed from src/core/swap.js)2
-rw-r--r--src/data.js5
-rw-r--r--src/data/support.js25
-rw-r--r--src/effects.js9
-rw-r--r--src/effects/animatedSelector.js (renamed from src/effects/animated-selector.js)0
-rw-r--r--src/effects/support.js76
-rw-r--r--src/event.js12
-rw-r--r--src/event/support.js23
-rw-r--r--src/jquery.js4
-rw-r--r--src/manipulation.js30
-rw-r--r--src/manipulation/support.js78
-rw-r--r--src/support.js267
-rw-r--r--src/traversing.js3
-rw-r--r--src/var/support.js4
23 files changed, 676 insertions, 356 deletions
diff --git a/src/ajax/xhr.js b/src/ajax/xhr.js
index ab5bd5e1e..0217ce0f4 100644
--- a/src/ajax/xhr.js
+++ b/src/ajax/xhr.js
@@ -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;
diff --git a/src/attributes/attr.js b/src/attributes/attr.js
index 6fb4d7f7f..916f64093 100644
--- a/src/attributes/attr.js
+++ b/src/attributes/attr.js
@@ -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
diff --git a/src/attributes/prop.js b/src/attributes/prop.js
index 490f2ef4a..0acd62a2c 100644
--- a/src/attributes/prop.js
+++ b/src/attributes/prop.js
@@ -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";
}
diff --git a/src/attributes/support.js b/src/attributes/support.js
new file mode 100644
index 000000000..5d4be1aa4
--- /dev/null
+++ b/src/attributes/support.js
@@ -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;
+
+});
diff --git a/src/attributes/val.js b/src/attributes/val.js
index 074d23f8c..e25249fb1 100644
--- a/src/attributes/val.js
+++ b/src/attributes/val.js
@@ -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
diff --git a/src/core.js b/src/core.js
index cc13f1ed3..5fdec9175 100644
--- a/src/core.js
+++ b/src/core.js
@@ -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 );
}
});
diff --git a/src/css.js b/src/css.js
index 68ffb8e83..660ed7df6 100644
--- a/src/css.js
+++ b/src/css.js
@@ -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 );
+ }
+ };
});
diff --git a/src/css/hidden-visible-selectors.js b/src/css/hiddenVisibleSelectors.js
index 9145304c0..0bd86c80f 100644
--- a/src/css/hidden-visible-selectors.js
+++ b/src/css/hiddenVisibleSelectors.js
@@ -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 ) {
diff --git a/src/css/support.js b/src/css/support.js
new file mode 100644
index 000000000..afbe27815
--- /dev/null
+++ b/src/css/support.js
@@ -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;
+
+});
diff --git a/src/core/swap.js b/src/css/swap.js
index 95f4e2c69..07a661c03 100644
--- a/src/core/swap.js
+++ b/src/css/swap.js
@@ -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 = {};
diff --git a/src/data.js b/src/data.js
index 545f041b3..de7268ef8 100644
--- a/src/data.js
+++ b/src/data.js
@@ -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 ];
diff --git a/src/data/support.js b/src/data/support.js
new file mode 100644
index 000000000..52250b21d
--- /dev/null
+++ b/src/data/support.js
@@ -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;
+
+});
diff --git a/src/effects.js b/src/effects.js
index e708cb32b..e64bf045a 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -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 ];
diff --git a/src/effects/animated-selector.js b/src/effects/animatedSelector.js
index 290e32bfa..290e32bfa 100644
--- a/src/effects/animated-selector.js
+++ b/src/effects/animatedSelector.js
diff --git a/src/effects/support.js b/src/effects/support.js
new file mode 100644
index 000000000..0299cae4e
--- /dev/null
+++ b/src/effects/support.js
@@ -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;
+
+});
diff --git a/src/event.js b/src/event.js
index d0e16bb1e..3ec6e400c 100644
--- a/src/event.js
+++ b/src/event.js
@@ -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
diff --git a/src/event/support.js b/src/event/support.js
new file mode 100644
index 000000000..1912b8430
--- /dev/null
+++ b/src/event/support.js
@@ -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;
+
+});
diff --git a/src/jquery.js b/src/jquery.js
index 2c63e3606..5c3d27ff8 100644
--- a/src/jquery.js
+++ b/src/jquery.js
@@ -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",
diff --git a/src/manipulation.js b/src/manipulation.js
index faa11eb28..b98b08ce9 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -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++ ) {
diff --git a/src/manipulation/support.js b/src/manipulation/support.js
new file mode 100644
index 000000000..fda9db6ce
--- /dev/null
+++ b/src/manipulation/support.js
@@ -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;
+
+});
diff --git a/src/support.js b/src/support.js
index 705a5b0fd..832f192d5 100644
--- a/src/support.js
+++ b/src/support.js
@@ -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.
- // Setup
- div.setAttribute( "className", "t" );
- div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+ 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];
- // Finish early in limited (non-browser) environments
- all = div.getElementsByTagName("*") || [];
- a = div.getElementsByTagName("a")[ 0 ];
- if ( !a || !a.style || !all.length ) {
- return support;
+ if ( !body ) {
+ // Return for frameset docs that don't have a body
+ return;
}
- // First batch of tests
- select = document.createElement("select");
- opt = select.appendChild( document.createElement("option") );
- input = div.getElementsByTagName("input")[ 0 ];
-
- 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;
+ // Setup
+ div.setAttribute( "className", "t" );
+ div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
- // Tests for enctype support on a form (#6743)
- support.enctype = !!document.createElement("form").enctype;
+ container = document.createElement( "div" );
+ container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
- // 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>";
+ body.appendChild( container ).appendChild( div );
- // 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%;";
-
- // 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 );
- }
+ div.style.cssText = divReset + "width:1px;padding:1px;display:inline;zoom:1";
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 );
- 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;
+});
});
diff --git a/src/traversing.js b/src/traversing.js
index 84b8af09f..5d4c5025b 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -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,
diff --git a/src/var/support.js b/src/var/support.js
new file mode 100644
index 000000000..b25dbc74b
--- /dev/null
+++ b/src/var/support.js
@@ -0,0 +1,4 @@
+define(function() {
+ // All support tests are defined in their respective modules.
+ return {};
+});