From 1662d931e95759114fd960f981c846dbbc38ed4c Mon Sep 17 00:00:00 2001 From: Dustin Diaz Date: Tue, 13 Dec 2011 15:12:20 -0800 Subject: [PATCH] - minor cosmetics. bump minor version for 'form' checks --- package.json | 2 +- qwery.js | 21 ++++++++++----------- qwery.min.js | 2 +- src/qwery.js | 19 +++++++++---------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 1e0f8c8..ad8bfec 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "qwery" , "description": "blazing fast CSS3 query selector engine" - , "version": "3.2.0" + , "version": "3.2.2" , "homepage": "https://github.com/ded/qwery" , "author": "Dustin Diaz (http://dustindiaz.com)" , "contributors": [ diff --git a/qwery.js b/qwery.js index 49e1f46..f957486 100644 --- a/qwery.js +++ b/qwery.js @@ -221,22 +221,21 @@ return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root)) } - function isNode(el) { - return el && typeof el === 'object' && el.nodeType && (el.nodeType == 1 || el.nodeType == 9) + function isNode(el, t) { + return el && typeof el === 'object' && (t = el.nodeType) && (t == 1 || t == 9) } function uniq(ar) { - var r = [], i = 0, j = 0, k, item, inIt - for (; item = ar[i]; ++i) { - inIt = false - for (k = 0; k < r.length; ++k) { - if (r[k] === item) { - inIt = true; break + var a = [], i, j + o: for (i = 0; i < ar.length; ++i) { + for (j = 0; j < a.length; ++j) { + if (a[j] == ar[i]) { + continue o } } - if (!inIt) r[j++] = item + a[a.length] = ar[i] } - return r + return a } function arrayLike(o) { @@ -246,7 +245,7 @@ function normalizeRoot(root) { if (!root) return doc if (typeof root == 'string') return qwery(root)[0] - if (arrayLike(root)) return root[0] + if (!root.nodeType && arrayLike(root)) return root[0] return root } diff --git a/qwery.min.js b/qwery.min.js index 4fc7b01..65e4512 100644 --- a/qwery.min.js +++ b/qwery.min.js @@ -4,4 +4,4 @@ * copyright Dustin Diaz & Jacob Thornton 2011 * MIT License */ -!function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&typeof define.amd=="object"?define(b):this[a]=b()}("qwery",function(){function B(){this.c={}}function G(a){return C.g(a)||C.s(a,new RegExp("(^|\\s+)"+a+"(\\s+|$)"))}function H(a,b){var c=0,d=a.length;for(;c~+]/,p=/^\s+|\s*([,\s\+\~>]|$)\s*/g,q=/[\s\>\+\~]/,r=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,s=/([.*+?\^=!:${}()|\[\]\/\\])/g,t=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,u=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,v=/:([\w\-]+)(\(['"]?([\s\w\+\-]+)['"]?\))?/,w=new RegExp("("+q.source+")"+r.source,"g"),x=new RegExp(q.source+r.source),y=new RegExp(t.source+"("+u.source+")?"+"("+v.source+")?"),z=/^(([\w\-]*[#\.]?[\w\-]+|\*)?(\[[\w\-]+([\~\|]?=['"][ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+["'])?\])?(\:(link|visited|active|hover))?([\s>+~\.,]|(?:$)))+$/,A={" ":function(a){return a&&a!==d&&a.parentNode},">":function(a,b){return a&&a.parentNode==b.parentNode&&a.parentNode},"~":function(a){return a&&a.previousSibling},"+":function(a,b,c,d){return a?(c=K(a))&&(d=K(b))&&c==d&&c:!1}};B.prototype={g:function(a){return this.c[a]||undefined},s:function(a,b){return this.c[a]=b}};var C=new B,D=new B,E=new B,F=new B,Z="compareDocumentPosition"in d?function(a,b){return(b.compareDocumentPosition(a)&16)==16}:"contains"in d?function(a,b){return b=b.nodeType===9||b==window?d:b,b!==a&&b.contains(a)}:function(a,b){while(a=a.parentNode)if(a===b)return 1;return 0},$=function(){var a=b.createElement("p");return(a.innerHTML='x')&&a.firstChild.getAttribute("href")!="#x"?function(a,b){return b==="class"?a.className:b==="href"||b==="src"?a.getAttribute(b,2):a.getAttribute(b)}:function(a,b){return a.getAttribute(b)}}(),_=function(){if(b[e]&&b.querySelector&&b[g])try{var a=b.createElement("p");return a.innerHTML="",a[g](":nth-of-type(1)").length}catch(c){}return!1}(),ba=function(a,b){var c=[],d,e;try{return b.nodeType===9||!o.test(a)?J(b[g](a)):(H(d=a.split(","),Y(b,function(a,b){e=a[g](b),e.length==1?c[c.length]=e.item(0):e.length&&(c=c.concat(J(e)))})),d.length>1&&c.length>1?T(c):c)}catch(f){}return bc(a,b)},bb=function(a,b){var c,d,e,f,h=[];return a=a.replace(p,"$1"),!o.test(a)&&z.test(a)?J(b[g](a)):(H(f=a.split(","),Y(b,function(a,f,i){d=z.test(f)?a[g](f):P(f,a);for(c=0,e=d.length;c1&&h.length>1?T(h):h)},bc=function(a,b){var c=[],d,e,g,h,i,j;a=a.replace(p,"$1");if(e=a.match(m)){i=G(e[2]),d=b[f](e[1]||"*");for(g=0,h=d.length;g1&&c.length>1?T(c):c},bd=_?ba:b[g]?bb:bc;return X.uniq=T,X.is=Q,X.pseudos={},X.noConflict=function(){return a.qwery=c,this},X}) \ No newline at end of file +!function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&typeof define.amd=="object"?define(b):this[a]=b()}("qwery",function(){function B(){this.c={}}function G(a){return C.g(a)||C.s(a,new RegExp("(^|\\s+)"+a+"(\\s+|$)"))}function H(a,b){var c=0,d=a.length;for(;c~+]/,p=/^\s+|\s*([,\s\+\~>]|$)\s*/g,q=/[\s\>\+\~]/,r=/(?![\s\w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^'"]*\]|[\s\w\+\-]*\))/,s=/([.*+?\^=!:${}()|\[\]\/\\])/g,t=/^(\*|[a-z0-9]+)?(?:([\.\#]+[\w\-\.#]+)?)/,u=/\[([\w\-]+)(?:([\|\^\$\*\~]?\=)['"]?([ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+)["']?)?\]/,v=/:([\w\-]+)(\(['"]?([\s\w\+\-]+)['"]?\))?/,w=new RegExp("("+q.source+")"+r.source,"g"),x=new RegExp(q.source+r.source),y=new RegExp(t.source+"("+u.source+")?"+"("+v.source+")?"),z=/^(([\w\-]*[#\.]?[\w\-]+|\*)?(\[[\w\-]+([\~\|]?=['"][ \w\-\/\?\&\=\:\.\(\)\!,@#%<>\{\}\$\*\^]+["'])?\])?(\:(link|visited|active|hover))?([\s>+~\.,]|(?:$)))+$/,A={" ":function(a){return a&&a!==d&&a.parentNode},">":function(a,b){return a&&a.parentNode==b.parentNode&&a.parentNode},"~":function(a){return a&&a.previousSibling},"+":function(a,b,c,d){return a?(c=K(a))&&(d=K(b))&&c==d&&c:!1}};B.prototype={g:function(a){return this.c[a]||undefined},s:function(a,b){return this.c[a]=b}};var C=new B,D=new B,E=new B,F=new B,Z="compareDocumentPosition"in d?function(a,b){return(b.compareDocumentPosition(a)&16)==16}:"contains"in d?function(a,b){return b=b.nodeType===9||b==window?d:b,b!==a&&b.contains(a)}:function(a,b){while(a=a.parentNode)if(a===b)return 1;return 0},$=function(){var a=b.createElement("p");return(a.innerHTML='x')&&a.firstChild.getAttribute("href")!="#x"?function(a,b){return b==="class"?a.className:b==="href"||b==="src"?a.getAttribute(b,2):a.getAttribute(b)}:function(a,b){return a.getAttribute(b)}}(),_=function(){if(b[e]&&b.querySelector&&b[g])try{var a=b.createElement("p");return a.innerHTML="",a[g](":nth-of-type(1)").length}catch(c){}return!1}(),ba=function(a,b){var c=[],d,e;try{return b.nodeType===9||!o.test(a)?J(b[g](a)):(H(d=a.split(","),Y(b,function(a,b){e=a[g](b),e.length==1?c[c.length]=e.item(0):e.length&&(c=c.concat(J(e)))})),d.length>1&&c.length>1?T(c):c)}catch(f){}return bc(a,b)},bb=function(a,b){var c,d,e,f,h=[];return a=a.replace(p,"$1"),!o.test(a)&&z.test(a)?J(b[g](a)):(H(f=a.split(","),Y(b,function(a,f,i){d=z.test(f)?a[g](f):P(f,a);for(c=0,e=d.length;c1&&h.length>1?T(h):h)},bc=function(a,b){var c=[],d,e,g,h,i,j;a=a.replace(p,"$1");if(e=a.match(m)){i=G(e[2]),d=b[f](e[1]||"*");for(g=0,h=d.length;g1&&c.length>1?T(c):c},bd=_?ba:b[g]?bb:bc;return X.uniq=T,X.is=Q,X.pseudos={},X.noConflict=function(){return a.qwery=c,this},X}) \ No newline at end of file diff --git a/src/qwery.js b/src/qwery.js index 801643c..0d84578 100644 --- a/src/qwery.js +++ b/src/qwery.js @@ -214,22 +214,21 @@ return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root)) } - function isNode(el) { - return el && typeof el === 'object' && el.nodeType && (el.nodeType == 1 || el.nodeType == 9) + function isNode(el, t) { + return el && typeof el === 'object' && (t = el.nodeType) && (t == 1 || t == 9) } function uniq(ar) { - var r = [], i = 0, j = 0, k, item, inIt - for (; item = ar[i]; ++i) { - inIt = false - for (k = 0; k < r.length; ++k) { - if (r[k] === item) { - inIt = true; break + var a = [], i, j + o: for (i = 0; i < ar.length; ++i) { + for (j = 0; j < a.length; ++j) { + if (a[j] == ar[i]) { + continue o } } - if (!inIt) r[j++] = item + a[a.length] = ar[i] } - return r + return a } function arrayLike(o) {