Skip to content

Commit 9903376

Browse files
committed
degradeInputs now uses the recently introduced keepNativeSelector()
1 parent 7c34c5d commit 9903376

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

js/jquery.mobile.degradeInputs.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ $.mobile.page.prototype.options.degradeInputs = {
2323
week: false
2424
};
2525

26-
$.mobile.page.prototype.options.keepNative = ":jqmData(role='none'), :jqmData(role='nojs')";
27-
2826

2927
//auto self-init widgets
3028
$( document ).bind( "pagecreate create", function( e ){
3129

32-
var o = $.mobile.page.prototype.options;
30+
var page = $(e.target).closest(':jqmData(role="page")').data("page"),
31+
o = page.options;
3332

3433
// degrade inputs to avoid poorly implemented native functionality
35-
$( e.target ).find( "input" ).not( o.keepNative ).each(function() {
34+
$( e.target ).find( "input" ).not( page.keepNativeSelector() ).each(function() {
3635
var $this = $( this ),
3736
type = this.getAttribute( "type" ),
3837
optType = o.degradeInputs[ type ] || "text";

tests/unit/degradeInputs/degradeInputs.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
*/
44

55
(function($){
6+
7+
68
module('jquery.mobile.slider.js', {
79
setup: function() {
810
$('#test-container').html("");
911
}
1012
});
1113

14+
test('keepNative elements should not be degraded', function() {
15+
same($('input#not-to-be-degraded').attr("type"), "range");
16+
});
17+
1218
test('input type color should not degrade when "create" event is triggered', function(){
1319
$('#test-container').html('<input type="color" />').trigger("create");
1420

tests/unit/degradeInputs/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ <h2 id="qunit-userAgent"></h2>
2727

2828
<div id="foo" data-nstest-role="page">
2929

30+
<input id="not-to-be-degraded" type="range" data-nstest-role="nojs" />
31+
3032
<div id="test-container">
3133
</div>
3234

0 commit comments

Comments
 (0)