Skip to content
This repository
Browse code

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...
commit 6bd8f7a85b760d21ef21c8949807a047d3213bfd 1 parent de75527
Kin Blas authored November 11, 2011
6  js/jquery.mobile.buttonMarkup.js
@@ -73,8 +73,8 @@ $.fn.buttonMarkup = function( options ) {
73 73
 			buttonClass += " ui-shadow";
74 74
 		}
75 75
 
76  
-		el.attr( "data-" + $.mobile.ns + "theme", o.theme )
77  
-			.addClass( buttonClass );
  76
+		e.setAttribute( "data-" + $.mobile.ns + "theme", o.theme );
  77
+		el.addClass( buttonClass );
78 78
 
79 79
 		buttonInner.className = innerClass;
80 80
 		buttonInner.setAttribute("aria-hidden", "true");
@@ -96,7 +96,7 @@ $.fn.buttonMarkup = function( options ) {
96 96
 		// TODO obviously it would be nice to pull this element out instead of
97 97
 		// retrieving it from the DOM again, but this change is much less obtrusive
98 98
 		// and 1.0 draws nigh
99  
-		el.data( 'textWrapper', $( buttonText ) );
  99
+		$.data( e, 'textWrapper', $( buttonText ) );
100 100
 	}
101 101
 
102 102
 	return this;
20  js/jquery.mobile.listview.js
@@ -115,7 +115,21 @@ $.widget( "mobile.listview", $.mobile.widget, {
115 115
 		}
116 116
 		return null;
117 117
 	},
118  
-	
  118
+	_getChildrenByTagName: function( ele, lcName, ucName )
  119
+	{
  120
+		var results = [],
  121
+			dict = {};
  122
+		dict[ lcName ] = dict[ ucName ] = true;
  123
+		ele = ele.firstChild;
  124
+		while ( ele ) {
  125
+			if ( dict[ ele.nodeName ] ) {
  126
+				results.push( ele );
  127
+			}
  128
+			ele = ele.nextSibling;
  129
+		}
  130
+		return $( results );
  131
+	},
  132
+
119 133
 	_addThumbClasses: function( containers )
120 134
 	{
121 135
 		var i, img, len = containers.length;
@@ -138,7 +152,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
138 152
 			dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme,
139 153
 			listsplittheme = $list.jqmData( "splittheme" ),
140 154
 			listspliticon = $list.jqmData( "spliticon" ),
141  
-			li = $list.children( "li" ),
  155
+			li = this._getChildrenByTagName( $list[ 0 ], "li", "LI" ),
142 156
 			counter = $.support.cssPseudoElement || !$.nodeName( $list[ 0 ], "ol" ) ? 0 : 1,
143 157
 			item, itemClass, itemTheme,
144 158
 			a, last, splittheme, countParent, icon, imgParents, img;
@@ -154,7 +168,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
154 168
 			// If we're creating the element, we update it regardless
155 169
 			if ( create || !item.hasClass( "ui-li" ) ) {
156 170
 				itemTheme = item.jqmData("theme") || o.theme;
157  
-				a = item.children( "a" );
  171
+				a = this._getChildrenByTagName( item[ 0 ], "a", "A" );
158 172
 
159 173
 				if ( a.length ) {
160 174
 					icon = item.jqmData("icon");

0 notes on commit 6bd8f7a

Please sign in to comment.
Something went wrong with that request. Please try again.