Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Uh, yeah, I'll take back another 700 msecs on WP7.5 (Mango) and 200 m…

…secs on iPad. Thank You.

- Don't set the item class on the list item or it's btn-inner children until after the main processing loop. We now use a dictionary of item-classes to track what items get what set of classes and then set them all afterwards. This cuts down the per-item addClass() and children() function overhead significantly and gets us big wins on platforms like WP 7.5
  • Loading branch information...
commit 3353649a2982248b4d96ebb0b8fe370ee8962cd8 1 parent 0e0435e
@jblas jblas authored
Showing with 21 additions and 1 deletion.
  1. +21 −1 js/jquery.mobile.listview.js
View
22 js/jquery.mobile.listview.js
@@ -154,6 +154,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
listspliticon = $list.jqmData( "spliticon" ),
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
+ itemClassDict = {},
item, itemClass, itemTheme,
a, last, splittheme, countParent, icon, imgParents, img;
@@ -238,7 +239,26 @@ $.widget( "mobile.listview", $.mobile.widget, {
.prepend( "<span class='ui-li-dec'>" + (counter++) + ". </span>" );
}
- item.addClass( itemClass ).children( ".ui-btn-inner" ).addClass( itemClass );
+ // Instead of setting item class directly on the list item and its
+ // btn-inner at this point in time, push the item into a dictionary
+ // that tells us what class to set on it so we can do this after this
+ // processing loop is finished.
+
+ if ( !itemClassDict[ itemClass ] ) {
+ itemClassDict[ itemClass ] = [];
+ }
+
+ itemClassDict[ itemClass ].push( item[ 0 ] );
+ }
+
+ // Set the appropriate listview item classes on each list item
+ // and their btn-inner elements. The main reason we didn't do this
+ // in the for-loop above is because we can eliminate per-item function overhead
+ // by calling addClass() and children() once or twice afterwards. This
+ // can give us a significant boost on platforms like WP7.5.
+
+ for ( itemClass in itemClassDict ) {
+ $( itemClassDict[ itemClass ] ).addClass( itemClass ).children( ".ui-btn-inner" ).addClass( itemClass );
}
$list.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" )
Please sign in to comment.
Something went wrong with that request. Please try again.