Permalink
Browse files

Reclaiming another 200-300 msecs on the 400 listview item page for iP…

…ad and WP7.5.

- Use $.data() instead of $.fn.data() in buttonMarkup().
- Avoid excess function overhead with a filtered children() call by walking the DOM ourselves in listview code.
  • Loading branch information...
jblas committed Nov 11, 2011
1 parent de75527 commit 6bd8f7a85b760d21ef21c8949807a047d3213bfd
Showing with 20 additions and 6 deletions.
  1. +3 −3 js/jquery.mobile.buttonMarkup.js
  2. +17 −3 js/jquery.mobile.listview.js
@@ -73,8 +73,8 @@ $.fn.buttonMarkup = function( options ) {
buttonClass += " ui-shadow";
}
el.attr( "data-" + $.mobile.ns + "theme", o.theme )
.addClass( buttonClass );
e.setAttribute( "data-" + $.mobile.ns + "theme", o.theme );
el.addClass( buttonClass );
buttonInner.className = innerClass;
buttonInner.setAttribute("aria-hidden", "true");
@@ -96,7 +96,7 @@ $.fn.buttonMarkup = function( options ) {
// TODO obviously it would be nice to pull this element out instead of
// retrieving it from the DOM again, but this change is much less obtrusive
// and 1.0 draws nigh
el.data( 'textWrapper', $( buttonText ) );
$.data( e, 'textWrapper', $( buttonText ) );
}
return this;
@@ -115,7 +115,21 @@ $.widget( "mobile.listview", $.mobile.widget, {
}
return null;
},
_getChildrenByTagName: function( ele, lcName, ucName )
{
var results = [],
dict = {};
dict[ lcName ] = dict[ ucName ] = true;
ele = ele.firstChild;
while ( ele ) {
if ( dict[ ele.nodeName ] ) {
results.push( ele );
}
ele = ele.nextSibling;
}
return $( results );
},
_addThumbClasses: function( containers )
{
var i, img, len = containers.length;
@@ -138,7 +152,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme,
listsplittheme = $list.jqmData( "splittheme" ),
listspliticon = $list.jqmData( "spliticon" ),
li = $list.children( "li" ),
li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
item, itemClass, itemTheme,
a, last, splittheme, countParent, icon, imgParents, img;
@@ -154,7 +168,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
// If we're creating the element, we update it regardless
if ( create || !item.hasClass( "ui-li" ) ) {
itemTheme = item.jqmData("theme") || o.theme;
a = item.children( "a" );
a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
if ( a.length ) {
icon = item.jqmData("icon");

0 comments on commit 6bd8f7a

Please sign in to comment.