From e056d20728d032eebe0e63ec4384b31fc902bdbd Mon Sep 17 00:00:00 2001 From: "jblas@adobe.com" Date: Tue, 1 Nov 2011 14:57:31 -0700 Subject: [PATCH] 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. --- js/jquery.mobile.listview.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index c2181ff5..317875ad 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -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 }); }, @@ -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 ); },