Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Page: Manipulate correct class in response to "theme" option change
Browse files Browse the repository at this point in the history
The "theme" option should result in the manipulation of class "ui-page-theme-*",
not "ui-body-*"

Fixes #6668
  • Loading branch information
Gabriel Schulhof committed Jan 2, 2014
1 parent 30c669a commit 2b04726
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/widgets/page.js
Expand Up @@ -131,7 +131,7 @@ $.widget( "mobile.page", {

_setOptions: function( o ) {
if ( o.theme !== undefined ) {
this.element.removeClass( "ui-body-" + this.options.theme ).addClass( "ui-body-" + o.theme );
this.element.removeClass( "ui-page-theme-" + this.options.theme ).addClass( "ui-page-theme-" + o.theme );
}

if ( o.contentTheme !== undefined ) {
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/page/page_core.js
Expand Up @@ -51,6 +51,13 @@
ok( $( "#a" ).hasClass( "ui-page-theme-" + themedefault ) );
});

test( "setting option 'theme' on page updates classes correctly", function() {
$( "#a" ).page( "option", "theme", "x" );
deepEqual( $( "#a" ).hasClass( "ui-page-theme-x" ), true, "After setting option 'theme' to 'x', the page has the new theme class" );
deepEqual( $( "#a" ).hasClass( "ui-page-theme-" + themedefault ), false, "After setting option 'theme', the page does not have default theme class" );
$( "#a" ).page( "option", "theme", themedefault );
});

test( "B page has non-default theme matching its data-theme attr" , function(){
$( "#b" ).page();
var btheme = $( "#b" ).jqmData( "theme" );
Expand Down

0 comments on commit 2b04726

Please sign in to comment.