Skip to content

Commit

Permalink
Fix problem with appending multiple string arguments in IE 6. Fixes #…
Browse files Browse the repository at this point in the history
…9072.
  • Loading branch information
jeresig committed May 3, 2011
1 parent 3cdffce commit bfad45f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/manipulation.js
Expand Up @@ -582,7 +582,7 @@ jQuery.extend({
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
}

var ret = [];
var ret = [], j;

This comment has been minimized.

Copy link
@mathiasbynens

mathiasbynens May 3, 2011

Contributor

Why not declare i and elem here as well then? They’re all in the same scope.

This comment has been minimized.

Copy link
@timmywil

timmywil May 3, 2011

Member

No objections here. Think we were more concerned with breaking dom manipulation. ;)


for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
if ( typeof elem === "number" ) {
Expand Down Expand Up @@ -628,7 +628,7 @@ jQuery.extend({
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 ) {
tbody[ j ].parentNode.removeChild( tbody[ j ] );
}
Expand All @@ -649,8 +649,8 @@ jQuery.extend({
var len;
if ( !jQuery.support.appendChecked ) {
if ( elem[0] && typeof (len = elem.length) === "number" ) {
for ( i = 0; i < len; i++ ) {
findInputs( elem[i] );
for ( j = 0; j < len; j++ ) {
findInputs( elem[j] );
}
} else {
findInputs( elem );
Expand Down
13 changes: 12 additions & 1 deletion test/unit/manipulation.js
Expand Up @@ -227,7 +227,7 @@ test("unwrap()", function() {
});

var testAppend = function(valueObj) {
expect(40);
expect(41);
var defaultText = "Try them out:"
var result = jQuery("#first").append(valueObj("<b>buga</b>"));
equals( result.text(), defaultText + "buga", "Check if text appending works" );
Expand Down Expand Up @@ -344,6 +344,17 @@ var testAppend = function(valueObj) {
equals( $radio[0].checked, true, "Reappending radios uphold which radio is checked" );
equals( $radioNot[0].checked, false, "Reappending radios uphold not being checked" );
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() {
Expand Down

0 comments on commit bfad45f

Please sign in to comment.