diff --git a/js/jquery.mobile.listview.filter.js b/js/jquery.mobile.listview.filter.js old mode 100644 new mode 100755 index ebbcc2bdad4..4d8d4024a2f --- a/js/jquery.mobile.listview.filter.js +++ b/js/jquery.mobile.listview.filter.js @@ -44,8 +44,7 @@ $( ":jqmData(role='listview')" ).live( "listviewcreate", function() { // Change val as lastval for next execution $this.jqmData( "lastval" , val ); - - change = val.replace( new RegExp( "^" + lastval ) , "" ); + change = val.substr( 0 , lastval.length - 1 ).replace( lastval , "" ); if ( val.length < lastval.length || change.length != ( val.length - lastval.length ) ) { diff --git a/tests/unit/listview/listview_core.js b/tests/unit/listview/listview_core.js old mode 100644 new mode 100755 index 80fa59e91ed..26ba63e3ad4 --- a/tests/unit/listview/listview_core.js +++ b/tests/unit/listview/listview_core.js @@ -332,10 +332,8 @@ $searchPage.find('input').val('at'); $searchPage.find('input').trigger('change'); - setTimeout(function() { - same($searchPage.find('li.ui-screen-hidden').length, 2); - start(); - }, 1000); + same($searchPage.find('li.ui-screen-hidden').length, 2); + start(); } ]); }); @@ -351,14 +349,29 @@ $searchPage.find('input').val('a'); $searchPage.find('input').trigger('change'); - setTimeout(function() { - same($searchPage.find("li[style^='display: none;']").length, 0); - start(); - }, 1000); + same($searchPage.find("li[style^='display: none;']").length, 0); + start(); } ]); }); + asyncTest( "Filter works fine with \\W- or regexp-special-characters", function() { + var $searchPage = $(searchFilterId); + $.testHelper.pageSequence([ + function() { + $.testHelper.openPage(searchFilterId); + }, + + function() { + $searchPage.find('input').val('*'); + $searchPage.find('input').trigger('change'); + + same($searchPage.find('li.ui-screen-hidden').length, 4); + start(); + } + ]); + }); + test( "Refresh applies thumb styling", function(){ var ul = $('.ui-page-active ul'); @@ -441,7 +454,7 @@ $li = $page.find( "li:visible" ); ok($li.first().hasClass( "ui-corner-top" ), $li.length+" li elements: First visible element should have class ui-corner-top"); ok($li.last().hasClass( "ui-corner-bottom" ), $li.length+" li elements: Last visible element should have class ui-corner-bottom"); - } + }; $.testHelper.pageSequence([ function() {