some tweaking and minor cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-06-21 20:19:15 +03:00
parent 43496dafc8
commit f5d7fa4d95

View File

@ -302,14 +302,16 @@ var BrowserPrototype = {
// Filter the elements via a function... // Filter the elements via a function...
// .filter(<function>) // .filter(<function>)
// -> elements // -> elements
// NOTE: the elements passed to the <function> on each iteration
// are unwrapped for compatibility with jQuery API.
// //
// Get specific element... // Get specific element...
// .filter(<index>) // .filter(<index>)
// .filter(<jQuery-obj>) // .filter(<jQuery-obj>)
// -> element // -> element
// -> $() // -> $()
// NOTE: when passing a jQuery-obj it will be return iff it's an // NOTE: when passing a jQuery-obj it will be returned iff it's
// element. // an element.
// NOTE: unlike .select(..) index overflow will produce empty // NOTE: unlike .select(..) index overflow will produce empty
// lists rather than to/bottom elements. // lists rather than to/bottom elements.
// //
@ -323,6 +325,7 @@ var BrowserPrototype = {
// elements will be searched too. // elements will be searched too.
// //
// //
//
// Extended string patterns: // Extended string patterns:
// //
// The pattern string is split by whitespace and each resulting // The pattern string is split by whitespace and each resulting
@ -331,21 +334,18 @@ var BrowserPrototype = {
// //
// Examples: // Examples:
// 'aaa' - matches any element containing 'aaa' // 'aaa' - matches any element containing 'aaa'
// same as: /aaa/ // (Same as: /aaa/)
// 'aa bb' - matches any element containing both 'aa' // 'aa bb' - matches any element containing both 'aa'
// AND 'bb' in any order. // AND 'bb' in any order.
// same as: /aa.*bb|bb.*aa/ // (Same as: /aa.*bb|bb.*aa/)
// //
// NOTE: currently there is no way to search for whitespace explicitly,
// at this point this is "by-design" as an experiment on how
// vital this feature is.
// //
// //
// TODO need to support glob / nested patterns... // TODO need to support glob / nested patterns...
// ..things like /**/a*/*moo/ // ..things like /**/a*/*moo/
//
// XXX should we filter by jQuery object???
// ...i.e. return argument if it is an item...
// XXX Q: should we unwrap the elements to be more compatible with
// jQuery .filter(..)?
// ...currently I don't think so...
filter: function(pattern, a, b){ filter: function(pattern, a, b){
pattern = pattern == null ? '*' : pattern pattern = pattern == null ? '*' : pattern
var ignore_disabled = typeof(a) == typeof(true) ? a : b var ignore_disabled = typeof(a) == typeof(true) ? a : b
@ -364,6 +364,7 @@ var BrowserPrototype = {
// function... // function...
if(typeof(pattern) == typeof(function(){})){ if(typeof(pattern) == typeof(function(){})){
var filter = function(i, e){ var filter = function(i, e){
e = e[0]
if(!pattern.call(e, i, e)){ if(!pattern.call(e, i, e)){
if(rejected){ if(rejected){
rejected.call(e, i, e) rejected.call(e, i, e)