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

Commit 55d8989

Browse files
committed
Merge pull request #2492 from hpbuniat/search-filter-bar-2416
Fix for #2416
2 parents a78fce4 + 68e2839 commit 55d8989

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

js/jquery.mobile.listview.filter.js

100644100755
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ $( ":jqmData(role='listview')" ).live( "listviewcreate", function() {
4444

4545
// Change val as lastval for next execution
4646
$this.jqmData( "lastval" , val );
47-
48-
change = val.replace( new RegExp( "^" + lastval ) , "" );
47+
change = val.substr( 0 , lastval.length - 1 ).replace( lastval , "" );
4948

5049
if ( val.length < lastval.length || change.length != ( val.length - lastval.length ) ) {
5150

tests/unit/listview/listview_core.js

100644100755
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,8 @@
332332
$searchPage.find('input').val('at');
333333
$searchPage.find('input').trigger('change');
334334

335-
setTimeout(function() {
336-
same($searchPage.find('li.ui-screen-hidden').length, 2);
337-
start();
338-
}, 1000);
335+
same($searchPage.find('li.ui-screen-hidden').length, 2);
336+
start();
339337
}
340338
]);
341339
});
@@ -351,14 +349,29 @@
351349
$searchPage.find('input').val('a');
352350
$searchPage.find('input').trigger('change');
353351

354-
setTimeout(function() {
355-
same($searchPage.find("li[style^='display: none;']").length, 0);
356-
start();
357-
}, 1000);
352+
same($searchPage.find("li[style^='display: none;']").length, 0);
353+
start();
358354
}
359355
]);
360356
});
361357

358+
asyncTest( "Filter works fine with \\W- or regexp-special-characters", function() {
359+
var $searchPage = $(searchFilterId);
360+
$.testHelper.pageSequence([
361+
function() {
362+
$.testHelper.openPage(searchFilterId);
363+
},
364+
365+
function() {
366+
$searchPage.find('input').val('*');
367+
$searchPage.find('input').trigger('change');
368+
369+
same($searchPage.find('li.ui-screen-hidden').length, 4);
370+
start();
371+
}
372+
]);
373+
});
374+
362375
test( "Refresh applies thumb styling", function(){
363376
var ul = $('.ui-page-active ul');
364377

@@ -441,7 +454,7 @@
441454
$li = $page.find( "li:visible" );
442455
ok($li.first().hasClass( "ui-corner-top" ), $li.length+" li elements: First visible element should have class ui-corner-top");
443456
ok($li.last().hasClass( "ui-corner-bottom" ), $li.length+" li elements: Last visible element should have class ui-corner-bottom");
444-
}
457+
};
445458

446459
$.testHelper.pageSequence([
447460
function() {

0 commit comments

Comments
 (0)