Skip to content

Commit

Permalink
Merge e34dd82 into 3ea4f0e
Browse files Browse the repository at this point in the history
  • Loading branch information
neonstalwart committed Feb 19, 2015
2 parents 3ea4f0e + e34dd82 commit a0cca0c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea/
.DS_Store
.monitor
.*.swp
Expand Down
39 changes: 39 additions & 0 deletions test/keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,45 @@ test("adding multiple widgets", function (assert) {
assert.end()
})

test('3 elements in a container, insert an element after each', function (assert) {
function item(key) {
key = key.toString()
return h('div', {key: key, id: key}, key)
}

function container(children) {
return h('div', children)
}

var threeItems = container([
item(0),
item(2),
item(4)
])

var sixItems = container([
item(0),
item(1),
item(2),
item(3),
item(4),
item(5)
])

var rootNode = render(threeItems)
rootNode = patch(rootNode, diff(threeItems, sixItems))

function expectTextOfChild(childNo, text) {
assert.equal(rootNode.childNodes[childNo].id, text)
}

for (var i = 0; i <= 5; i++) {
expectTextOfChild(i, i.toString())
}

assert.end();
})

function childNodesArray(node) {
var childNodes = []
for (var i = 0; i < node.childNodes.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion vdom/patch-op.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function reorderChildren(domNode, bIndex) {
}

// the moved element came from the front of the array so reduce the insert offset
if (move + chainLength < i) {
if (move + chainLength <= i) {
insertOffset--
}
}
Expand Down

0 comments on commit a0cca0c

Please sign in to comment.