X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fselector%2Fselector.js;h=a78cb310f7a4c3769610e421d9df2e8251e5bf9e;hb=bdb5dad8e521c060980e3efecb53b81b15ce74b0;hp=13fd09428b20704797fbb8e1b5db59c9426ff4ab;hpb=fd249ca808408166882847c217d55ae4c5a799e8;p=jquery.git diff --git a/src/selector/selector.js b/src/selector/selector.js index 13fd094..a78cb31 100644 --- a/src/selector/selector.js +++ b/src/selector/selector.js @@ -16,7 +16,7 @@ jQuery.extend({ // Child Checks "first-child": "a.parentNode.getElementsByTagName('*')[0]==a", "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a", - "only-child": "a.parentNode.getElementsByTagName('*').length==1", + "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')", // Parent Checks parent: "a.firstChild", @@ -53,7 +53,7 @@ jQuery.extend({ // The regular expressions that power the parsing engine parse: [ // Match: [@value='test'], [@foo] - /^\[ *(@)([\w-]+) *([!*$^=]*) *('?"?)(.*?)\4 *\]/, + /^\[ *(@)([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/, // Match: [div], [div p] /^(\[)\s*(.*?(\[.*?\])?[^[]*?)\s*\]/, @@ -63,7 +63,7 @@ jQuery.extend({ // Match: :even, :last-chlid, #id, .class new RegExp("^([:.#]*)(" + - ( jQuery.chars = "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)") + ( jQuery.chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ? "(?:[\\w*_-]|\\\\.)" : "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)" ) + "+)") ], multiFilter: function( expr, elems, not ) { @@ -134,7 +134,7 @@ jQuery.extend({ // Perform our own iteration and filter for ( var i = 0; ret[i]; i++ ) for ( var c = ret[i].firstChild; c; c = c.nextSibling ) - if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName == nodeName.toUpperCase()) ) + if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) ) r.push( c ); ret = r; @@ -157,7 +157,7 @@ jQuery.extend({ if ( n.nodeType == 1 ) { if ( m == "~" && n.mergeNum == mergeNum ) break; - if (!nodeName || n.nodeName == nodeName.toUpperCase() ) { + if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) { if ( m == "~" ) n.mergeNum = mergeNum; r.push( n ); } @@ -193,7 +193,7 @@ jQuery.extend({ t = " " + t.substr(1,t.length); } else { - // Optomize for the case nodeName#idName + // Optimize for the case nodeName#idName var re2 = new RegExp("^(" + jQuery.chars + "+)(#)(" + jQuery.chars + "+)"); var m = re2.exec(t); @@ -340,14 +340,14 @@ jQuery.extend({ var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ]; if ( z == null || /href|src/.test(m[2]) ) - z = jQuery.attr(a,m[2]); + z = jQuery.attr(a,m[2]) || ''; if ( (type == "" && !!z || type == "=" && z == m[5] || type == "!=" && z != m[5] || type == "^=" && z && !z.indexOf(m[5]) || type == "$=" && z.substr(z.length - m[5].length) == m[5] || - type == "*=" && z.indexOf(m[5]) >= 0) ^ not ) + (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not ) tmp.push( a ); } @@ -377,7 +377,7 @@ jQuery.extend({ var add = false; if ( first == 1 ) { - if ( node.nodeIndex == last ) + if ( last == 0 || node.nodeIndex == last ) add = true; } else if ( (node.nodeIndex + last) % first == 0 ) add = true;