Ensure Enumerable#grep can handle strings with RegExp metacharacters. [#257 state:resolved]
This commit is contained in:
parent
e9e8c7fbe5
commit
9f5c40c744
|
@ -1,3 +1,5 @@
|
|||
* Ensure Enumerable#grep can handle strings with RegExp metacharacters. (Marton Kiss-Albert, kangax)
|
||||
|
||||
* Switch to the "doScroll approach" for the dom:loaded custom event. (javier, Diego Perini, Nick Stakenburg, Andrew Dupont)
|
||||
|
||||
* Optimize document.viewport.get(Dimensions|Width|Height). (Nick Stakenburg, Andrew Dupont)
|
||||
|
|
|
@ -75,7 +75,7 @@ var Enumerable = (function() {
|
|||
var results = [];
|
||||
|
||||
if (Object.isString(filter))
|
||||
filter = new RegExp(filter);
|
||||
filter = new RegExp(RegExp.escape(filter));
|
||||
|
||||
this.each(function(value, index) {
|
||||
if (filter.match(value))
|
||||
|
|
|
@ -136,6 +136,14 @@ new Test.Unit.Runner({
|
|||
|
||||
this.assertEnumEqual($('grepHeader', 'grepCell'),
|
||||
$('grepTable', 'grepTBody', 'grepRow', 'grepHeader', 'grepCell').grep(new Selector('.cell')));
|
||||
|
||||
// troublesome characters
|
||||
this.assertEnumEqual(['?a', 'c?'], ['?a','b','c?'].grep('?'));
|
||||
this.assertEnumEqual(['*a', 'c*'], ['*a','b','c*'].grep('*'));
|
||||
this.assertEnumEqual(['+a', 'c+'], ['+a','b','c+'].grep('+'));
|
||||
this.assertEnumEqual(['{1}a', 'c{1}'], ['{1}a','b','c{1}'].grep('{1}'));
|
||||
this.assertEnumEqual(['(a', 'c('], ['(a','b','c('].grep('('));
|
||||
this.assertEnumEqual(['|a', 'c|'], ['|a','b','c|'].grep('|'));
|
||||
},
|
||||
|
||||
testInclude: function() {
|
||||
|
|
Loading…
Reference in New Issue