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

Commit

Permalink
Toolbar: Leave anchors marked data-role="none" unenhanced
Browse files Browse the repository at this point in the history
Fixes gh-6875
  • Loading branch information
Gabriel Schulhof committed Jan 31, 2014
1 parent aea0f99 commit eb8d2ba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion js/widgets/toolbar.js
Expand Up @@ -95,7 +95,10 @@ define( [

// Deprecated in 1.4. As from 1.5 button classes have to be present in the markup.
_btnMarkup: function() {
this.element.children( "a" ).attr( "data-" + $.mobile.ns + "role", "button" );
this.element
.children( "a" )
.filter( ":not([data-" + $.mobile.ns + "role='none'])" )
.attr( "data-" + $.mobile.ns + "role", "button" );
this.element.trigger( "create" );
},
// Deprecated in 1.4. As from 1.5 ui-btn-left/right classes have to be present in the markup.
Expand Down
11 changes: 8 additions & 3 deletions tests/integration/toolbar/index.html
Expand Up @@ -14,14 +14,15 @@
<script>
$.testHelper.asyncLoad([
[
"widgets/toolbar"
"widgets/toolbar",
"jquery.mobile.buttonMarkup"
],
[ "jquery.mobile.init" ],
[ "toolbar_core.js" ]
]);
</script>

<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>

Expand All @@ -32,7 +33,11 @@
<div id="qunit"></div>

<div data-nstest-role="page">
<div data-role="content">
<div data-nstest-role="header" id="start-page-header">
<a href="#">Left Link</a>
<a href="#" data-nstest-role="none">Right Link</a>
</div>
<div class="ui-content">
<a href="#page2" id="go-to-page2">Go</a>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/toolbar/toolbar_core.js
Expand Up @@ -2,6 +2,14 @@

module( "Toolbar" );

test( "Links are auto-enhanced, unless data-role is set to 'none'", function() {
var leftLink = $( "#start-page-header a:first" ),
rightLink = $( "#start-page-header a:last" );

deepEqual( leftLink.hasClass( "ui-btn" ), true, "Left link has been enhanced" );
deepEqual( rightLink.hasClass( "ui-btn" ), false, "Right link has not been enhanced" );
});

asyncTest( "Back button appears correctly", function() {

expect( 2 );
Expand Down

0 comments on commit eb8d2ba

Please sign in to comment.