@@ -644,7 +644,8 @@ jQuery.extend({
644644 } ,
645645
646646 clean : function ( elems , context , fragment , scripts ) {
647- var checkScriptType ;
647+ var checkScriptType , script , j ,
648+ ret = [ ] ;
648649
649650 context = context || document ;
650651
@@ -653,8 +654,6 @@ jQuery.extend({
653654 context = context . ownerDocument || context [ 0 ] && context [ 0 ] . ownerDocument || document ;
654655 }
655656
656- var ret = [ ] , j ;
657-
658657 for ( var i = 0 , elem ; ( elem = elems [ i ] ) != null ; i ++ ) {
659658 if ( typeof elem === "number" ) {
660659 elem += "" ;
@@ -762,16 +761,17 @@ jQuery.extend({
762761 return ! elem . type || rscriptType . test ( elem . type ) ;
763762 } ;
764763 for ( i = 0 ; ret [ i ] ; i ++ ) {
765- if ( scripts && jQuery . nodeName ( ret [ i ] , "script" ) && ( ! ret [ i ] . type || ret [ i ] . type . toLowerCase ( ) === "text/javascript" ) ) {
766- scripts . push ( ret [ i ] . parentNode ? ret [ i ] . parentNode . removeChild ( ret [ i ] ) : ret [ i ] ) ;
764+ script = ret [ i ] ;
765+ if ( scripts && jQuery . nodeName ( script , "script" ) && ( ! script . type || rscriptType . test ( script . type ) ) ) {
766+ scripts . push ( script . parentNode ? script . parentNode . removeChild ( script ) : script ) ;
767767
768768 } else {
769- if ( ret [ i ] . nodeType === 1 ) {
770- var jsTags = jQuery . grep ( ret [ i ] . getElementsByTagName ( "script" ) , checkScriptType ) ;
769+ if ( script . nodeType === 1 ) {
770+ var jsTags = jQuery . grep ( script . getElementsByTagName ( "script" ) , checkScriptType ) ;
771771
772772 ret . splice . apply ( ret , [ i + 1 , 0 ] . concat ( jsTags ) ) ;
773773 }
774- fragment . appendChild ( ret [ i ] ) ;
774+ fragment . appendChild ( script ) ;
775775 }
776776 }
777777 }
0 commit comments