aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes
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/attributes
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/attributes')
-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
4 files changed, 79 insertions, 16 deletions
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