Skip to content

Commit

Permalink
Correct arguments for 'replaceWith' callback
Browse files Browse the repository at this point in the history
Ensure that when `replaceWith` is invoked with a function, that function
is invoked with both the iteration index *and* element.
  • Loading branch information
jugglinmike committed Mar 6, 2014
1 parent aa0cc40 commit 380663e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/api/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var replaceWith = exports.replaceWith = function(content) {
index;

if (_.isFunction(content)) {
dom = makeDomArray(content.call(el, i));
dom = makeDomArray(content.call(el, i, el));
}

// In the case that `dom` contains nodes that already exist in other
Expand Down
6 changes: 5 additions & 1 deletion test/api.manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,11 @@ describe('$(...)', function() {
return '<li class="first">';
});

expect(args).to.eql([[0], [1], [2]]);
expect(args).to.eql([
[0, origChildren[0]],
[1, origChildren[1]],
[2, origChildren[2]]
]);
expect(thisValues).to.eql([
origChildren[0],
origChildren[1],
Expand Down

0 comments on commit 380663e

Please sign in to comment.