Skip to content

Commit

Permalink
Some minor listview tweaking to eliminate 1200 $.fn.find calls in our…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
jblas committed Nov 1, 2011
1 parent ebd7e04 commit e056d20
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions js/jquery.mobile.listview.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,8 @@ $.widget( "mobile.listview", $.mobile.widget, {
}

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

Expand Down Expand Up @@ -215,6 +209,14 @@ $.widget( "mobile.listview", $.mobile.widget, {
self._itemApply( $list, item );
}

$list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ).end()
.find( "p, dl" ).addClass( "ui-li-desc" ).end()
.find( ".ui-li-aside" ).each(function() {
var $this = $(this);
$this.prependTo( $this.parent() ); //shift aside to front for css float
});


this._refreshCorners( create );
},

Expand Down

0 comments on commit e056d20

Please sign in to comment.