Permalink
Browse files

Move fixChecked function definition out of clean and out of the for loop

  • Loading branch information...
timmywil
timmywil committed Apr 17, 2011
1 parent ac39d0c commit 54b3fb8c29b8ddb5da82be51bc9358f902056894
Showing with 16 additions and 12 deletions.
  1. +16 −12 src/manipulation.js
View
@@ -509,6 +509,18 @@ function getAll( elem ) {
}
}
+// Used in clean, fixes the defaultChecked property
+// on all inputs and checkboxes within html recursively
+function fixChecked( elem ) {
+ if ( jQuery.nodeName( elem, "input" ) ) {
+ if ( elem.type === "checkbox" || elem.type === "radio" ) {
+ elem.defaultChecked = elem.checked;
+ }
+ } else if ( elem.getElementsByTagName ) {
+ jQuery.grep( elem.getElementsByTagName("input"), fixChecked );
+ }
+}
+
jQuery.extend({
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
var clone = elem.cloneNode(true),
@@ -558,7 +570,7 @@ jQuery.extend({
},
clean: function( elems, context, fragment, scripts ) {
- var checkScriptType, fixChecked, len;
+ var checkScriptType;
context = context || document;
@@ -629,18 +641,10 @@ jQuery.extend({
}
}
- // Resets defaultChecked for any radios and checkboxes about to be appended to the DOM in IE 6/7 (#8060)
+ // Resets defaultChecked for any radios and checkboxes
+ // about to be appended to the DOM in IE 6/7 (#8060)
+ var len;
if ( !jQuery.support.appendChecked ) {
- fixChecked = function( elem ) {
- if ( jQuery.nodeName( elem, "input" ) ) {
- if ( elem.type === "checkbox" || elem.type === "radio" ) {
- elem.defaultChecked = elem.checked;
- }
- } else if ( elem.getElementsByTagName ) {
- jQuery.grep( elem.getElementsByTagName("input"), fixChecked );
- }
- };
-
if ( elem[0] && typeof (len = elem.length) === "number" ) {
for ( i = 0; i < len; i++ ) {
fixChecked( elem[i] );

0 comments on commit 54b3fb8

Please sign in to comment.