Fix problem with appending multiple string arguments in IE 6. Fixes #9072.

This commit is contained in:
John Resig 2011-05-03 15:02:26 -04:00
parent 3cdffce19f
commit bfad45fe45
2 changed files with 16 additions and 5 deletions

View file

@ -582,7 +582,7 @@ jQuery.extend({
context = context.ownerDocument || context[0] && context[0].ownerDocument || document; context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
} }
var ret = []; var ret = [], j;
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) { if ( typeof elem === "number" ) {
@ -628,7 +628,7 @@ jQuery.extend({
div.childNodes : div.childNodes :
[]; [];
for ( var j = tbody.length - 1; j >= 0 ; --j ) { for ( j = tbody.length - 1; j >= 0 ; --j ) {
if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
tbody[ j ].parentNode.removeChild( tbody[ j ] ); tbody[ j ].parentNode.removeChild( tbody[ j ] );
} }
@ -649,8 +649,8 @@ jQuery.extend({
var len; var len;
if ( !jQuery.support.appendChecked ) { if ( !jQuery.support.appendChecked ) {
if ( elem[0] && typeof (len = elem.length) === "number" ) { if ( elem[0] && typeof (len = elem.length) === "number" ) {
for ( i = 0; i < len; i++ ) { for ( j = 0; j < len; j++ ) {
findInputs( elem[i] ); findInputs( elem[j] );
} }
} else { } else {
findInputs( elem ); findInputs( elem );

View file

@ -227,7 +227,7 @@ test("unwrap()", function() {
}); });
var testAppend = function(valueObj) { var testAppend = function(valueObj) {
expect(40); expect(41);
var defaultText = "Try them out:" var defaultText = "Try them out:"
var result = jQuery("#first").append(valueObj("<b>buga</b>")); var result = jQuery("#first").append(valueObj("<b>buga</b>"));
equals( result.text(), defaultText + "buga", "Check if text appending works" ); equals( result.text(), defaultText + "buga", "Check if text appending works" );
@ -344,6 +344,17 @@ var testAppend = function(valueObj) {
equals( $radio[0].checked, true, "Reappending radios uphold which radio is checked" ); equals( $radio[0].checked, true, "Reappending radios uphold which radio is checked" );
equals( $radioNot[0].checked, false, "Reappending radios uphold not being checked" ); equals( $radioNot[0].checked, false, "Reappending radios uphold not being checked" );
QUnit.reset(); QUnit.reset();
var prev = jQuery("#sap").children().length;
jQuery("#sap").append(
"<span></span>",
"<span></span>",
"<span></span>"
);
equals( jQuery("#sap").children().length, prev + 3, "Make sure that multiple arguments works." );
QUnit.reset();
} }
test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() { test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {