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() { ...@@ -116,6 +116,12 @@ describe('Functional', function() {
116 expect(el.getElementsByTagName('li').length).toBe(2); 116 expect(el.getElementsByTagName('li').length).toBe(2);
117 }); 117 });
118 118
119 it('should not fail if the collection being bound to is null', function() {
120 data.set({ items: null});
121 rivets.bind(el, bindData);
122 expect(el.getElementsByTagName('li').length).toBe(0);
123 });
124
119 it('should re-loop over the collection and create new instances when the array changes', function() { 125 it('should re-loop over the collection and create new instances when the array changes', function() {
120 rivets.bind(el, bindData); 126 rivets.bind(el, bindData);
121 expect(el.getElementsByTagName('li').length).toBe(2); 127 expect(el.getElementsByTagName('li').length).toBe(2);
...@@ -162,6 +168,7 @@ describe('Functional', function() { ...@@ -162,6 +168,7 @@ describe('Functional', function() {
162 expect(el.getElementsByTagName('li')[2]).toHaveTheTextContent('b'); 168 expect(el.getElementsByTagName('li')[2]).toHaveTheTextContent('b');
163 expect(el.getElementsByTagName('li')[3]).toHaveTheTextContent('last'); 169 expect(el.getElementsByTagName('li')[3]).toHaveTheTextContent('last');
164 }) 170 })
171
165 }); 172 });
166 }); 173 });
167 174
......
...@@ -339,6 +339,7 @@ Rivets.binders = ...@@ -339,6 +339,7 @@ Rivets.binders =
339 339
340 @iterated = [] 340 @iterated = []
341 341
342 if collection
342 for item in collection 343 for item in collection
343 data = {} 344 data = {}
344 data[n] = m for n, m of @view.models 345 data[n] = m for n, m of @view.models
......