]> source.dussan.org Git - jquery.git/commitdiff
Combine the support tests for radioValue and appendChecked
authortimmywil <tim.willison@thisismedium.com>
Fri, 22 Apr 2011 04:27:52 +0000 (00:27 -0400)
committertimmywil <tim.willison@thisismedium.com>
Fri, 22 Apr 2011 04:27:52 +0000 (00:27 -0400)
src/attributes.js
src/support.js

index a296ad112d2fb306eee72508a75d8fed2f383626..46582d8b0300e7c2bff76c96fed3aca1d1d2f112 100644 (file)
@@ -363,6 +363,7 @@ jQuery.extend({
                                } else if ( !jQuery.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 it's default in case type is set after value
+                                       // This is for element creation
                                        var val = elem.getAttribute("value");
                                        elem.setAttribute( "type", value );
                                        if ( val ) {
index 8f2beebbcd6de116fdbd98b8e3f1a9c31f8e8916..178bddf0598c15c6471327e22e496942643ed615 100644 (file)
@@ -115,13 +115,15 @@ jQuery.support = (function() {
                div.cloneNode( true ).fireEvent( "onclick" );
        }
 
+       // Check if a radio maintains it's value
+       // after being appended to the DOM
        input = document.createElement("input");
        input.value = "t";
        input.setAttribute("type", "radio");
        support.radioValue = input.value === "t";
 
-       div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
-
+       input.setAttribute("checked", "checked");
+       div.appendChild( input );
        fragment = document.createDocumentFragment();
        fragment.appendChild( div.firstChild );
 
@@ -148,6 +150,10 @@ jQuery.support = (function() {
        body.appendChild( div );
        document.documentElement.appendChild( body );
 
+       // Check if a disconnected checkbox will retain its checked
+       // value of true after appended to the DOM (IE6/7)
+       support.appendChecked = input.checked;
+
        support.boxModel = div.offsetWidth === 2;
 
        if ( "zoom" in div.style ) {
@@ -186,14 +192,6 @@ jQuery.support = (function() {
        support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
        div.innerHTML = "";
 
-       // Check if a disconnected checkbox will retain its checked
-       // value of true after appended to the DOM
-       input = document.createElement("input");
-       input.setAttribute("type", "checkbox");
-       input.checked = true;
-       div.appendChild( input );
-       support.appendChecked = input.checked;
-
        // Check if div with explicit width and no margin-right incorrectly
        // gets computed margin-right based on width of container. For more
        // info see bug #3333