14b3c772 by Michael Richards

Merge pull request #111 from terrancesnyder/Issue#110

Pull request for #110
2 parents 835f5406 36de3dba
......@@ -116,6 +116,12 @@ describe('Functional', function() {
expect(el.getElementsByTagName('li').length).toBe(2);
});
it('should not fail if the collection being bound to is null', function() {
data.set({ items: null});
rivets.bind(el, bindData);
expect(el.getElementsByTagName('li').length).toBe(0);
});
it('should re-loop over the collection and create new instances when the array changes', function() {
rivets.bind(el, bindData);
expect(el.getElementsByTagName('li').length).toBe(2);
......@@ -162,6 +168,7 @@ describe('Functional', function() {
expect(el.getElementsByTagName('li')[2]).toHaveTheTextContent('b');
expect(el.getElementsByTagName('li')[3]).toHaveTheTextContent('last');
})
});
});
......
......@@ -339,6 +339,7 @@ Rivets.binders =
@iterated = []
if collection
for item in collection
data = {}
data[n] = m for n, m of @view.models
......