airbnb / infinity

UITableViews for the web (DEPRECATED)
http://airbnb.io/infinity/
Other
2.8k stars 281 forks source link

Bug? Page.prototype.lazyload> calls optional lazyload function with Page as calling context instead of for each Listitem #32

Open 0xgeert opened 11 years ago

0xgeert commented 11 years ago

From the annotated source of Page.prototype.lazyload:

`Runs the given lazy-loading callback on all unloaded page content.

Takes: callback: a function of the form function([$el]){}. Will run on each unloaded element, and will use the element as its calling context.`

I take it this means that each 'unloaded element', is a ListItem correct? This would make sense: each lazyloaded page iterates it's containing listitems and calls the optionally supplied Lazyload-function on each of them.

However this is not what's happening in Page.prototype.lazyload. Instead $el[x] is passed to the lazyloadfunction. Since $el is a jquery-wrapper around the page-domelement, $el only contains 1 element ($el[0]) the page dom element itself.

instead, iterating over $el.children() instead would do the trick, if I'm right about what Page.prototype.lazyload is supposed to do that is.