Skip to content

Commit e056d20

Browse files
committed
Some minor listview tweaking to eliminate 1200 $.fn.find calls in our 400 item listview test case.
- Moved some of the finds we used to do for every item, out of the processing loop so we do just 3 big finds. This shaves off 200-300ms on iPad iOS 4.3.5.
1 parent ebd7e04 commit e056d20

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

js/jquery.mobile.listview.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
4343
}
4444

4545
// TODO class has to be defined in markup
46-
item.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ).end()
47-
.find( "p, dl" ).addClass( "ui-li-desc" ).end()
48-
.find( ">img:eq(0), .ui-link-inherit>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
46+
item.find( ">img:eq(0), .ui-link-inherit>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
4947
item.addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
50-
}).end()
51-
.find( ".ui-li-aside" ).each(function() {
52-
var $this = $(this);
53-
$this.prependTo( $this.parent() ); //shift aside to front for css float
5448
});
5549
},
5650

@@ -215,6 +209,14 @@ $.widget( "mobile.listview", $.mobile.widget, {
215209
self._itemApply( $list, item );
216210
}
217211

212+
$list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ).end()
213+
.find( "p, dl" ).addClass( "ui-li-desc" ).end()
214+
.find( ".ui-li-aside" ).each(function() {
215+
var $this = $(this);
216+
$this.prependTo( $this.parent() ); //shift aside to front for css float
217+
});
218+
219+
218220
this._refreshCorners( create );
219221
},
220222

0 commit comments

Comments
 (0)