diff options
author | Michał Gołębiowski <m.goleb@gmail.com> | 2013-08-27 00:54:13 +0200 |
---|---|---|
committer | Michał Gołębiowski <m.goleb@gmail.com> | 2013-09-06 03:38:22 +0200 |
commit | bbbdd947256a3fcd788fb9d4f306046082a1ef1f (patch) | |
tree | 2fc5a02969653d281a44a7b3ff6426b5561c8140 /src/attributes | |
parent | 776012b8b3898fad2e0727880f1dc4af5c7b33c1 (diff) | |
download | jquery-bbbdd947256a3fcd788fb9d4f306046082a1ef1f.tar.gz jquery-bbbdd947256a3fcd788fb9d4f306046082a1ef1f.zip |
Fix #10814. Make support tests lazy and broken out to components.
Diffstat (limited to 'src/attributes')
-rw-r--r-- | src/attributes/attr.js | 9 | ||||
-rw-r--r-- | src/attributes/prop.js | 6 | ||||
-rw-r--r-- | src/attributes/support.js | 35 | ||||
-rw-r--r-- | src/attributes/val.js | 8 |
4 files changed, 47 insertions, 11 deletions
diff --git a/src/attributes/attr.js b/src/attributes/attr.js index 170e6a39e..e47bde2f3 100644 --- a/src/attributes/attr.js +++ b/src/attributes/attr.js @@ -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; diff --git a/src/attributes/prop.js b/src/attributes/prop.js index 95462bbbb..f321b1ef7 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)$/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; diff --git a/src/attributes/support.js b/src/attributes/support.js new file mode 100644 index 000000000..aa9adf265 --- /dev/null +++ b/src/attributes/support.js @@ -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; + +}); diff --git a/src/attributes/val.js b/src/attributes/val.js index 73a3bf3ea..74d8c9c46 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; @@ -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 |