jquery selector: Replacing {0,1} for ? in a regex.
[jquery.git] / src / selector.js
index 9540119..9cc75fc 100644 (file)
@@ -246,7 +246,7 @@ var Expr = Sizzle.selectors = {
                ID: /#((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
                CLASS: /\.((?:[\w\u0128-\uFFFF_-]|\\.)+)/,
                NAME: /\[name=['"]*((?:[\w\u0128-\uFFFF_-]|\\.)+)['"]*\]/,
-               ATTR: /\[((?:[\w\u0128-\uFFFF_-]|\\.)+)\s*(?:(\S{0,1}=)\s*(['"]*)(.*?)\3|)\]/,
+               ATTR: /\[((?:[\w\u0128-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\]/,
                TAG: /^((?:[\w\u0128-\uFFFF\*_-]|\\.)+)/,
                CHILD: /:(only|nth|last|first)-child\(?(even|odd|[\dn+-]*)\)?/,
                POS: /:(nth|eq|gt|lt|first|last|even|odd)\(?(\d*)\)?(?:[^-]|$)/,
@@ -684,21 +684,22 @@ try {
 if ( document.querySelectorAll ) (function(){
        var oldSizzle = Sizzle;
        
-       Sizzle = function(query, context, extra){
+       Sizzle = function(query, context, extra, seed){
                context = context || document;
 
-               if ( context.nodeType === 9 ) {
+               if ( !seed && context.nodeType === 9 ) {
                        try {
                                return makeArray( context.querySelectorAll(query) );
                        } catch(e){}
                }
                
-               return oldSizzle(query, context, extra);
+               return oldSizzle(query, context, extra, seed);
        };
 
        Sizzle.find = oldSizzle.find;
        Sizzle.filter = oldSizzle.filter;
        Sizzle.selectors = oldSizzle.selectors;
+       Sizzle.matches = oldSizzle.matches;
 })();
 
 if ( document.documentElement.getElementsByClassName ) {
@@ -777,7 +778,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck ) {
 var contains = document.compareDocumentPosition ?  function(a, b){
        return a.compareDocumentPosition(b) & 16;
 } : function(a, b){
-       return a !== b && a.contains(b);
+       return a !== b && (a.contains ? a.contains(b) : true);
 };
 
 // EXPOSE