Skip to content
This repository
Browse code

little performance improvement for getInheritedTheme

  • Loading branch information...
commit 406b3d43497a72b8a74c79cb64bf633cc0e8b4c6 1 parent d9f8ec0
Hans-Peter Buniat authored May 29, 2012 johnbender committed June 01, 2012

Showing 1 changed file with 7 additions and 8 deletions. Show diff stats Hide diff stats

  1. 15  js/jquery.mobile.core.js
15  js/jquery.mobile.core.js 100644 → 100755
@@ -160,25 +160,24 @@ define( [ "jquery", "../external/requirejs/text!../version.txt", "./jquery.mobil
160 160
 			return nsNormalizeDict[ prop ] || ( nsNormalizeDict[ prop ] = $.camelCase( $.mobile.ns + prop ) );
161 161
 		},
162 162
 
  163
+        // Find the closest parent with a theme class on it. Note that
  164
+        // we are not using $.fn.closest() on purpose here because this
  165
+        // method gets called quite a bit and we need it to be as fast
  166
+        // as possible.
163 167
 		getInheritedTheme: function( el, defaultTheme ) {
164  
-
165  
-			// Find the closest parent with a theme class on it. Note that
166  
-			// we are not using $.fn.closest() on purpose here because this
167  
-			// method gets called quite a bit and we need it to be as fast
168  
-			// as possible.
169  
-
170 168
 			var e = el[ 0 ],
171 169
 				ltr = "",
172 170
 				re = /ui-(bar|body|overlay)-([a-z])\b/,
173  
-				c, m;
  171
+				m;
174 172
 
175 173
 			while ( e ) {
176 174
 				var c = e.className || "";
177  
-				if ( ( m = re.exec( c ) ) && ( ltr = m[ 2 ] ) ) {
  175
+				if ( c && ( m = re.exec( c ) ) && ( ltr = m[ 2 ] ) ) {
178 176
 					// We found a parent with a theme class
179 177
 					// on it so bail from this loop.
180 178
 					break;
181 179
 				}
  180
+
182 181
 				e = e.parentNode;
183 182
 			}
184 183
 

0 notes on commit 406b3d4

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