Permalink
Browse files

Controlgroup: Honor keepNative even for buttonMarkup()

Closes gh-7683
Fixes gh-7676
  • Loading branch information...
gabrielschulhof committed Sep 18, 2014
1 parent 4800f90 commit aa930a694aefeba2797019e65f20a95fc7993a00
View
@@ -24,16 +24,22 @@ $.widget( "mobile.controlgroup", $.extend( {
_create: function() {
var elem = this.element,
opts = this.options;
opts = this.options,
keepNative = $.mobile.page.prototype.keepNativeSelector();
// Run buttonmarkup
if ( $.fn.buttonMarkup ) {
this.element.find( $.fn.buttonMarkup.initSelector ).buttonMarkup();
this.element
.find( $.fn.buttonMarkup.initSelector )
.not( keepNative )
.buttonMarkup();
}
// Enhance child widgets
$.each( this._childWidgets, $.proxy( function( number, widgetName ) {
if ( $.mobile[ widgetName ] ) {
this.element.find( $.mobile[ widgetName ].initSelector ).not( $.mobile.page.prototype.keepNativeSelector() )[ widgetName ]();
this.element
.find( $.mobile[ widgetName ].initSelector )
.not( keepNative )[ widgetName ]();
}
}, this ));
@@ -0,0 +1,23 @@
test( "Controlgroup honors keepNative", function() {
deepEqual( !!$( "select.selectmenu-enhanced" ).data( "mobile-selectmenu" ), true,
"selectmenu instantiated where data-role='none' is absent" );
deepEqual( !!$( ".button-enhanced" ).data( "mobile-button" ), true,
"button instantiated where data-role='none' is absent" );
deepEqual( !!$( ".checkboxradio-enhanced" ).data( "mobile-checkboxradio" ), true,
"checkboxradio instantiated where data-role='none' is absent" );
deepEqual( $( "button.buttonMarkup-enhanced" ).hasClass( "ui-btn" ), true,
"button element enhanced where data-role='none' is absent" );
deepEqual( $( "a.buttonMarkup-enhanced" ).hasClass( "ui-btn" ), true,
"Anchor enhanced where data-role='none' is absent" );
deepEqual( !!$( "select.selectmenu-skipped" ).data( "mobile-selectmenu" ), false,
"selectmenu instantiation skipped where data-role='none' is present" );
deepEqual( !!$( ".button-skipped" ).data( "mobile-button" ), false,
"button instantiation skipped where data-role='none' is present" );
deepEqual( !!$( ".checkboxradio-skipped" ).data( "mobile-checkboxradio" ), false,
"checkboxradio instantiation skipped where data-role='none' is present" );
deepEqual( $( "button.buttonMarkup-skipped" ).hasClass( "ui-btn" ), false,
"button element enhancement skipped where data-role='none' is present" );
deepEqual( $( "a.buttonMarkup-skipped" ).hasClass( "ui-btn" ), false,
"Anchor enhancement skipped where data-role='none' is present" );
});
@@ -0,0 +1,65 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery Mobile Controlgroup Test Suite</title>
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
['widgets/page'],
[
"widgets/controlgroup",
"jquery.mobile.buttonMarkup",
"widgets/forms/select",
"widgets/forms/checkboxradio",
"widgets/forms/button"
],
[ "jquery.mobile.init" ],
[ "controlgroup_core.js" ]
]);
</script>
<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"/>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>
<div data-nstest-role="page">
<div data-nstest-role="content">
<div data-nstest-role="controlgroup" id="keep-native">
<select class="selectmenu-enhanced">
<option value="o1">Option 1</option>
<option value="o2">Option 2</option>
</select>
<button class="buttonMarkup-enhanced">Enhanced Button</button>
<a href="#" data-nstest-role="button" class="buttonMarkup-enhanced">Enhanced Anchor</a>
<input type="submit" value="Enhanced Input Button" class="button-enhanced">
<label>Enhanced Checkbox<input type="checkbox" class="checkboxradio-enhanced"></label>
<select class="selectmenu-skipped" data-nstest-role="none">
<option value="o1">Option 1</option>
<option value="o2">Option 2</option>
</select>
<button class="buttonMarkup-skipped" data-nstest-role="none">Skipped Button</button>
<a href="#" data-nstest-role="none" class="buttonMarkup-skipped">Skipped Anchor</a>
<input type="submit" data-nstest-role="none" value="Skipped Input Button" class="button-skipped">
<label>Skipped Checkbox<input type="checkbox" data-nstest-role="none" class="checkboxradio-skipped"></label>
</div>
</div>
</div>
</body>
</html>

0 comments on commit aa930a6

Please sign in to comment.