diff --git a/js/jquery.mobile.core.js b/js/jquery.mobile.core.js index 754950283cb..ece5a998597 100644 --- a/js/jquery.mobile.core.js +++ b/js/jquery.mobile.core.js @@ -128,17 +128,7 @@ }, getInheritedTheme: function( el, defaultTheme ) { - // Find the closest parent with a theme class on it. - var themedParent = el.closest( "[class*='ui-bar-'],[class*='ui-body-']" ), - - // If there's a themed parent, extract the theme letter - // from the theme class . - ltr = ( themedParent.length && /ui-(bar|body)-([a-z])\b/.exec( themedParent.attr( "class" ) )[ 2 ] || "" ) || ""; - - // Return the theme letter we found, if none, return the - // specified default. - - return ltr || defaultTheme || "a"; + return $( el ).inheritedTheme( defaultTheme ); } }); @@ -167,6 +157,15 @@ $.jqmRemoveData = function( elem, prop ) { return $.removeData( elem, $.mobile.nsNormalize( prop ) ); }; + + $.fn.inheritedTheme = function( defaultTheme ) { + var ltr; + this.parents("[class*='ui-bar-'],[class*='ui-body-']").each(function() { + ltr = ( ( ltr = /ui-(bar|body)-([a-z])\b/.exec( $(this).attr("class") ) ) && ltr[ 2 ]) || ""; + if (ltr) return false; + }); + return ltr || defaultTheme || "a"; + }; $.fn.removeWithDependents = function() { $.removeWithDependents( this );