1934 | | filter: function(t,r,not) { |
1935 | | // Figure out if we're doing regular, or inverse, filtering |
1936 | | var g = not !== false ? jQuery.grep : |
1937 | | function(a,f) {return jQuery.grep(a,f,true);}; |
1938 | | |
1939 | | while ( t && /^[a-z[({<*:.#]/i.test(t) ) { |
1940 | | |
1941 | | var p = jQuery.parse; |
1942 | | |
1943 | | for ( var i = 0; i < p.length; i++ ) { |
1944 | | |
1945 | | // Look for, and replace, string-like sequences |
1946 | | // and finally build a regexp out of it |
1947 | | var re = new RegExp( |
1948 | | "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" ); |
1949 | | |
1950 | | var m = re.exec( t ); |
1951 | | |
1952 | | if ( m ) { |
1953 | | // Re-organize the first match |
1954 | | if ( !i ) |
1955 | | m = ["",m[1], m[3], m[2], m[5]]; |
1956 | | |
1957 | | // Remove what we just matched |
1958 | | t = t.replace( re, "" ); |
1959 | | |
1960 | | break; |
1961 | | } |
1962 | | } |
1963 | | |
1964 | | // :not() is a special case that can be optimized by |
1965 | | // keeping it out of the expression list |
1966 | | if ( m[1] == ":" && m[2] == "not" ) |
1967 | | r = jQuery.filter(m[3],r,false).r; |
1968 | | |
1969 | | // Otherwise, find the expression to execute |
1970 | | else { |
1971 | | var f = jQuery.expr[m[1]]; |
1972 | | if ( f.constructor != String ) |
1973 | | f = jQuery.expr[m[1]][m[2]]; |
1974 | | |
1975 | | // Build a custom macro to enclose it |
1976 | | eval("f = function(a,i){" + |
1977 | | ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) + |
1978 | | "return " + f + "}"); |
1979 | | |
1980 | | // Execute it against the current filter |
1981 | | r = g( r, f ); |
1982 | | } |
1983 | | } |
1984 | | |
1985 | | // Return an array of filtered elements (r) |
1986 | | // and the modified expression string (t) |
1987 | | return { r: r, t: t }; |
1988 | | }, |
1989 | | |
| 1953 | filter: function(t,r,not) { |
| 1954 | // Figure out if we're doing regular, or inverse, filtering |
| 1955 | var g = not !== false ? jQuery.grep : |
| 1956 | function(a,f) {return jQuery.grep(a,f,true);}; |
| 1957 | |
| 1958 | while ( t && /^[a-z[({<*:.#]/i.test(t) ) { |
| 1959 | |
| 1960 | var p = jQuery.parse; |
| 1961 | |
| 1962 | for ( var i = 0; i < p.length; i++ ) { |
| 1963 | |
| 1964 | // Look for, and replace, string-like sequences |
| 1965 | // and finally build a regexp out of it |
| 1966 | var re = new RegExp( |
| 1967 | "^" + p[i].replace("S", "([a-z*_-][a-z0-9_-]*)"), "i" ); |
| 1968 | |
| 1969 | var m = re.exec( t ); |
| 1970 | |
| 1971 | if ( m ) { |
| 1972 | // Re-organize the first match |
| 1973 | if ( jQuery.expr[m[1]]["_resort"] ) |
| 1974 | m = ["",m[1], m[3], m[2], m[5]]; |
| 1975 | |
| 1976 | // Remove what we just matched |
| 1977 | t = t.replace( re, "" ); |
| 1978 | |
| 1979 | break; |
| 1980 | } |
| 1981 | } |
| 1982 | |
| 1983 | // :not() is a special case that can be optimized by |
| 1984 | // keeping it out of the expression list |
| 1985 | if ( m[1] == ":" && m[2] == "not" ) |
| 1986 | r = jQuery.filter(m[3],r,false).r; |
| 1987 | |
| 1988 | // Otherwise, find the expression to execute |
| 1989 | else { |
| 1990 | var f = jQuery.expr[m[1]]; |
| 1991 | if ( f.constructor != String ) |
| 1992 | f = jQuery.expr[m[1]][m[2]]; |
| 1993 | |
| 1994 | // Build a custom macro to enclose it |
| 1995 | eval("f = function(a,i){" + |
| 1996 | (jQuery.expr[m[1]]["_prefix"] || "") + |
| 1997 | "return " + f + "}"); |
| 1998 | |
| 1999 | // Execute it against the current filter |
| 2000 | r = g( r, f ); |
| 2001 | } |
| 2002 | } |
| 2003 | |
| 2004 | // Return an array of filtered elements (r) |
| 2005 | // and the modified expression string (t) |
| 2006 | return { r: r, t: t }; |
| 2007 | }, |
| 2008 | |