simplify and rethink...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-04-29 04:21:44 +03:00
parent e718df1bea
commit 1cfe064c03

View File

@ -931,18 +931,19 @@ var BaseBrowserPrototype = {
: {}
// normalize the test predicate...
// XXX add support for regex...
var func = (
// predicate...
pattern instanceof Function ?
pattern
// path...
// XXX BUG: this for some reason matches ['B', '*'] to ['nested', 'moo']
// XXX add support for regex...
: pattern instanceof Array ?
function(elem, i, path){
return path.length > 0
&& pattern.length == path.length
&& (pattern[path.length-1] == '*'
|| pattern[path.length-1] == path[path.length-1]) }
&& !pattern.reduce(function(res, e, i){
return res || (e != '*' && e != path[i]) }, false) }
// index...
: function(elem, i, path){
return elem