#126: Fixed replaceWith(). Works as expected, but tests are failing...#128
#126: Fixed replaceWith(). Works as expected, but tests are failing...#128ColemanGariety wants to merge 1 commit intoded:masterfrom
Conversation
|
oh man i feel silly for implementing this myself when this pull request was sitting here. tests still fail for me for |
|
@ded, implementation is buggy. original: return bonzo(this[0].parentNode.replaceChild(bonzo(normalize(node))[0], this[0]))new: var that = this
return this.each(function (el, i) {
each(normalize(node, that, i), function (i) {
el[parentNode] && el[parentNode].replaceChild(i, el)
})
})This test case is passing in an array with multiple elements and the new loop is now calling The fix is ... I don't know but you want to replace the child with a bunch of elements at once, not do a replacement for each element. |
|
(also, I still think the test is good so just make it pass and there will be world-peace and free puppies for every child) |
|
@rvagg So the first element in the passed array should replace, and the subsequent elements should be appended after? |
|
@JacksonGariety no, the whole array should replace whatever you're replacing. Even if it's three elements replacing one, I think. It's worth going off jQuery for these APIs because they aren't intuitive in the complex cases but people expect them to act in a certain way, because jQuery. |
|
@rvagg but
Right? |
...for the moment.