From 6bd8f7a85b760d21ef21c8949807a047d3213bfd Mon Sep 17 00:00:00 2001 From: "jblas@adobe.com" Date: Fri, 11 Nov 2011 14:51:58 -0800 Subject: [PATCH] Reclaiming another 200-300 msecs on the 400 listview item page for iPad 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. --- js/jquery.mobile.buttonMarkup.js | 6 +++--- js/jquery.mobile.listview.js | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/js/jquery.mobile.buttonMarkup.js b/js/jquery.mobile.buttonMarkup.js index 7b682ef8..edb87aa8 100644 --- a/js/jquery.mobile.buttonMarkup.js +++ b/js/jquery.mobile.buttonMarkup.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; diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index f80184ca..55feb481 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -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");