Skip to content
Browse files

fixed regular expression that prevented correct parsing of comma sepa…

…rated selectors when no whitespace 'div,a' issue #36 (pdanpdan)
  • Loading branch information...
1 parent 93175ee commit 351122604c0e4487d9926cdc3c4be6730c93a682 @dperini dperini committed
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/modules/nwmatcher-thin.js
  2. +1 −1 src/nwmatcher-base.js
  3. +1 −1 src/nwmatcher.js
View
4 src/modules/nwmatcher-thin.js
@@ -1,3 +1,3 @@
/*! NWMatcher 1.2.4 Selector Engine - Copyright (c) 2007-2011 Diego Perini & NWBOX All rights reserved */
-(function(r){var X='nwmatcher-1.2.4beta',k=typeof exports=='object'?exports:((r.NW||(r.NW={}))&&(r.NW.Dom||(r.NW.Dom={}))),j=r.document,y=j.documentElement,by=[].slice,Y,I,z,J,u,Z,ba,bb,bc,K='[#.:]?',bd='([~*^$|!]?={1})',s='[\\x20\\t\\n\\r\\f]*',be='[\\x20]|[>+~][^>+~]',bf='[-+]?\\d*n?[-+]?\\d*',L='"[^"]*"'+"|'[^']*'",M='\\[.*\\]|\\(.*\\)|\\{.*\\}',m='(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',A='(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',bg='('+L+'|'+A+')',w=s+'('+m+'+:?'+m+'+)'+s+'(?:'+bd+s+bg+')?'+s,bm=w.replace(bg,'([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),B='((?:'+bf+'|'+L+'|'+K+'|'+m+'+|\\['+w+'\\]|\\(.+\\)|'+s+'|,)+)',bn='.+',N='(?=[\\x20\\t\\n\\r\\f]*[^>+~(){}<>])(\\*|(?:'+K+A+')|'+be+'|\\['+w+'\\]|\\('+B+'\\)|\\{'+bn+'\\}|,.)+',bo=N.replace(B,'.*'),C=RegExp(N,'g'),O=RegExp('^'+s+'|'+s+'$','g'),P=RegExp('([^,\\\\\\[\\]]+|\\[[^[\\]]*\\]|\\[.*\\]|\\([^()]+\\)|\\(.*\\)|\\{[^{}]+\\}|\\{.*\\}|\\\\.)+','g'),bp=RegExp('(\\['+w+'\\]|\\('+B+'\\)|[^\\x20>+~]|\\\\.)+','g'),bq=/[\x20\t\n\r\f]+/g,br=RegExp(A+'|^$'),v={},x={'=':"n=='%m'",'^=':"n.indexOf('%m')==0",'*=':"n.indexOf('%m')>-1",'|=':"(n+'-').indexOf('%m-')==0",'~=':"(' '+n+' ').indexOf(' %m ')>-1",'$=':"n.substr(n.length-'%m'.length)=='%m'"},D={ID:RegExp('^\\*?#('+m+'+)|'+M),TAG:RegExp('^('+m+'+)|'+M),CLASS:RegExp('^\\*?\\.('+m+'+$)|'+M)},o={universal:/^\*(.*)/,id:RegExp('^#('+m+'+)(.*)'),tagName:RegExp('^('+m+'+)(.*)'),className:RegExp('^\\.('+m+'+)(.*)'),attribute:RegExp('^\\['+bm+'\\](.*)'),children:/^[\x20\t\n\r\f]*\>[\x20\t\n\r\f]*(.*)/,adjacent:/^[\x20\t\n\r\f]*\+[\x20\t\n\r\f]*(.*)/,relative:/^[\x20\t\n\r\f]*\~[\x20\t\n\r\f]*(.*)/,ancestor:/^[\x20\t\n\r\f]+(.*)/},Q,p,bh,bs='getElementsByTagName'in j,bt='getElementsByClassName'in j,bu={value:1,checked:1,selected:1},bi=typeof j.addEventListener!='function',bj='f&&f(c[k]);r[r.length]=c[k];continue main;',bv=bi?'if(e.nodeName<"A")continue;':'',q={CACHING:false,SIMPLENOT:true,USE_HTML5:false,USE_QSAPI:false},configure=function(a){for(var b in a){q[b]=!!a[b];if(b=='SIMPLENOT'){R={};E={};S={};F={};q['USE_QSAPI']=false;C=new RegExp(bo,'g')}else if(b=='USE_QSAPI'){C=new RegExp(N,'g')}}},bw=function(a,b,d){var f=-1,c;while((c=b[++f]))d(a[a.length]=c);return a},l=function(a){if(typeof r.DOMException!=='undefined'){var b=Error();b.message='SYNTAX_ERR: (Selectors) '+a;b.code=12;throw b;}else{throw Error(12,'SYNTAX_ERR: (Selectors) '+a);}},G=function(a,b){var d=j;J=a;j=a.ownerDocument||a;if(b||d!=j){y=j.documentElement;p=j.createElement('DiV').nodeName=='DiV';bh=p?'.toUpperCase()':'';Q=p||typeof j.compatMode=='string'&&j.compatMode.indexOf('CSS')<0;q.CACHING&&k.setCache(true,j)}},T=function(a,b){var d=0,f=null;while((f=b[d])){if(f.getAttribute('id')==a){break}++d}return f},H=!('fileSize'in j)?function(a,b){a=a.replace(/\\/g,'');return b.getElementById&&b.getElementById(a)||T(a,b.getElementsByTagName('*'))}:function(a,b){var d=null;a=a.replace(/\\/g,'');if(p||b.nodeType!=9){return T(a,b.getElementsByTagName('*'))}if((d=b.getElementById(a))&&d.name==a&&b.getElementsByName){return T(a,b.getElementsByName(a))}return d},bx=function(a,b){G(b||(b=j));return H(a,b)},U=function(a,b,d){var f=typeof a=='string'?a.match(P):a;if(f.length==1){b+=(d?'e=c[k];':'e=k;')+bk(f[0],d?bj:'f&&f(k);return true;')}else{var c=-1,i={},e;while((e=f[++c])){e=e.replace(O,'');if(!i[e]&&(i[e]=true)){b+=(c>0?(d?'e=c[k];':'e=k;'):'')+bk(e,d?bj:'f&&f(k);return true;')}}}if(d)return Function('c,s,r,d,h,g,f','var N,n,x=0,k=-1,e;main:while((e=c[++k])){'+b+'}return r;');else return Function('e,s,r,d,h,g,f','var N,n,x=0,k=e;'+b+'return false;')},bk=function(a,b){var d=0,f,c,i,e,g,h;while(a){d++;if((c=a.match(o.universal))){h=''}else if((c=a.match(o.id))){b='if('+(p?'e.getAttribute("id")':'(e.submit?e.getAttribute("id"):e.id)')+'=="'+c[1]+'"){'+b+'}'}else if((c=a.match(o.tagName))){b='if(e.nodeName'+(p?'=="'+c[1]+'"':bh+'=="'+c[1].toUpperCase()+'"')+'){'+b+'}'}else if((c=a.match(o.className))){b='if((n='+(p?'e.getAttribute("class")':'e.className')+')&&n.length&&(" "+'+(Q?'n.toLowerCase()':'n')+'.replace('+bq+'," ")+" ").indexOf(" '+(Q?c[1].toLowerCase():c[1])+' ")>-1){'+b+'}'}else if((c=a.match(o.attribute))){if(c[2]&&!x[c[2]]){l('Unsupported operator in attribute selectors "'+a+'"');return''}if(c[2]&&c[4]&&(h=x[c[2]])){c[4]=c[4].replace(/\\([0-9a-f]{2,2})/,'\\x$1');f='n=(e.getAttribute("'+c[1]+'")+"").toLowerCase();';h=h.replace(/\%m/g,c[4].toLowerCase())}else if(c[2]=='!='||c[2]=='='){f='n=e.getAttribute("'+c[1]+'");';h='n'+c[2]+'="'+c[4]+'"'}else if(!c[2]){if(bu[c[1].toLowerCase()]){g='default'+c[1].charAt(0).toUpperCase()+c[1].slice(1).toLowerCase();f='n=e["'+g+'"];';h='n'}else{f='n=e.getAttributeNode("'+c[1]+'");';h='n&&n.specified'}}else{f='';h='false'}b=f+'if('+h+'){'+b+'}'}else if((c=a.match(o.adjacent))){b='var N'+d+'=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){'+b+'break;}}e=N'+d+';'}else if((c=a.match(o.relative))){b='var N'+d+'=e;e=e.parentNode.firstChild;while(e&&e!=N'+d+'){if(e.nodeName>"@"){'+b+'}e=e.nextSibling;}e=N'+d+';'}else if((c=a.match(o.children))){b='var N'+d+'=e;if(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else if((c=a.match(o.ancestor))){b='var N'+d+'=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else{f=false;e=true;for(f in v){if((c=a.match(v[f].Expression))&&c[1]){i=v[f].Callback(c,b);b=i.source;e=i.status;if(e)break}}if(!e){l('Unknown pseudo-class selector "'+a+'"');return''}if(!f){l('Unknown token in selector "'+a+'"');return''}}if(!c){l('Invalid syntax in selector "'+a+'"');return''}a=c&&c[c.length-1]}return b},V=function(a,b,d,f){var c;if(!(a&&a.nodeName>'@')){l('Invalid element argument');return false}else if(!b||typeof b!='string'){l('Invalid selector argument');return false}else if(J!=d){G(d||(d=a.ownerDocument))}b=b.replace(O,'');q.SHORTCUTS&&(b=NW.Dom.shortcuts(b,a,d));if(Z!=b){if((c=b.match(C))&&c[0]==b){Y=(c=b.match(P)).length<2;Z=b;bb=c}else{l('The string "'+b+'", is not a valid CSS selector');return false}}else c=bb;if(!E[b]||R[b]!==d){E[b]=U(Y?[b]:c,'',false);R[b]=d}return E[b](a,W,[],j,y,d,f)},bl=function(a,b,d){var f,c,i,e,g,h,t=a;if(arguments.length===0){l('Missing required selector parameters');return[]}else if(a===''){l('Empty selector string');return[]}else if(typeof a!='string'){return[]}else if(J!=b){G(b||(b=j))}if(q.CACHING&&(e=k.loadResults(t,b,j,y))){return d?bw([],e,d):e}a=a.replace(O,'');q.SHORTCUTS&&(a=NW.Dom.shortcuts(a,b));if((c=ba!=a)){if((g=a.match(C))&&g[0]==a){I=(g=a.match(P)).length<2;ba=a;bc=g}else{l('The string "'+a+'", is not a valid CSS selector');return[]}}else g=bc;if(b.nodeType==11){e=b.childNodes}else if(I){if(c){g=a.match(bp);h=g[g.length-1];z=h.split(':not')[0];u=a.length-h.length}if((g=z.match(D.ID))&&(h=g[1])){if((i=H(h,b))){if(V(i,a)){d&&d(i);e=[i]}else e=[]}}else if((g=a.match(D.ID))&&(h=g[1])){if((i=H(h,j))){if('#'+h==a){d&&d(i);e=[i]}if(/[>+~]/.test(a)){b=i.parentNode}else{a=a.replace('#'+h,'*');u-=h.length+1;b=i}}else e=[]}if(e){q.CACHING&&k.saveResults(t,b,j,e);return e}if(!p&&bs&&(g=z.match(D.TAG))&&(h=g[1])){if((e=b.getElementsByTagName(h)).length===0)return[];a=a.slice(0,u)+a.slice(u).replace(h,'*')}else if(!p&&bt&&(g=z.match(D.CLASS))&&(h=g[1])){if((e=b.getElementsByClassName(h.replace(/\\/g,''))).length===0)return[];a=a.slice(0,u)+a.slice(u).replace('.'+h,br.test(a.charAt(a.indexOf(h)-1))?'':'*')}}if(!e){if(bi){e=/^(?:applet|object)$/i.test(b.nodeName)?b.childNodes:b.getElementsByTagName('*');bv='if(e.nodeName<"A")continue;'}else{e=b.getElementsByTagName('*')}}if(!F[a]||S[a]!==b){F[a]=U(I?[a]:g,'',true);S[a]=b}e=F[a](e,W,[],j,y,b,d);q.CACHING&&k.saveResults(t,b,j,e);return e},R={},E={},S={},F={},W={byId:H,match:V,select:bl};Tokens={prefixes:K,encoding:m,operators:bd,whitespace:s,identifier:A,attributes:w,combinators:be,pseudoclass:B,pseudoparms:bf,quotedvalue:L};k.emit=l;k.byId=bx;k.match=V;k.select=bl;k.compile=U;k.configure=configure;k.Config=q;k.Operators=x;k.Selectors=v;k.Snapshot=W;k.Tokens=Tokens;k.setCache=function(){return};k.loadResults=function(){return};k.saveResults=function(){return};k.shortcuts=function(a){return a};k.registerOperator=function(a,b){x[a]||(x[a]=b)};k.registerSelector=function(a,b,d){v[a]||(v[a]={Expression:b,Callback:d})};G(j,true)})(this);
-(function(){var i={'a':1,'A':1,'area':1,'AREA':1,'link':1,'LINK':1},e=document.documentElement,g='compareDocumentPosition'in e?function(a,b){return(a.compareDocumentPosition(b)&16)==16}:'contains'in e?function(a,b){return b.nodeType==1&&a.contains(b)}:function(a,b){while((b=b.parentNode)&&b.nodeType==1){if(b===a)return true}return false},h=function(a){return a.getAttribute('href')&&i[a.nodeName]},t=function(a){a=a.firstChild;while(a){if(a.nodeType==3||a.nodeName>'@')return false;a=a.nextSibling}return true},r=function(a,b){var d=1,f=b?'nextSibling':'previousSibling';while((a=a[f])){if(a.nodeName>'@')++d}return d},X=function(a,b){var d=1,f=b?'nextSibling':'previousSibling',c=a.nodeName;while((a=a[f])){if(a.nodeName==c)++d}return d};NW.Dom.Snapshot['contains']=g;NW.Dom.Snapshot['isLink']=h;NW.Dom.Snapshot['isEmpty']=t;NW.Dom.Snapshot['nthOfType']=X;NW.Dom.Snapshot['nthElement']=r})();NW.Dom.registerSelector('nwmatcher:spseudos',/^\:((root|empty|nth-)?(?:(first|last|only)-)?(child)?-?(of-type)?)(?:\(([^\x29]*)\))?(.*)/,function(a,b){var d,f,c,i=true,e,g;switch(a[2]){case'root':if(a[7])b='if(e===h||s.contains(h,e)){'+b+'}';else b='if(e===h){'+b+'}';break;case'empty':b='if(s.isEmpty(e)){'+b+'}';break;default:if(a[2]&&a[6]){if(a[6]=='n'){b='if(e!==h){'+b+'}';break}else if(a[6]=='even'){d=2;c=0}else if(a[6]=='odd'){d=2;c=1}else{c=((f=a[6].match(/(-?\d+)$/))?parseInt(f[1],10):0);d=((f=a[6].match(/(-?\d*)n/))?parseInt(f[1],10):0);if(f&&f[1]=='-')d=-1}e=c<1&&d>1?'(n-('+c+'))%'+d+'==0':d>+1?(a[3]=='last')?'(n-('+c+'))%'+d+'==0':'n>='+c+'&&(n-('+c+'))%'+d+'==0':d<-1?(a[3]=='last')?'(n-('+c+'))%'+d+'==0':'n<='+c+'&&(n-('+c+'))%'+d+'==0':d===0?'n=='+c:(a[3]=='last')?d==-1?'n>='+c:'n<='+c:d==-1?'n<='+c:'n>='+c;b='if(e!==h){n=s['+(a[5]?'"nthOfType"':'"nthElement"')+'](e,'+(a[3]=='last'?'true':'false')+');if('+e+'){'+b+'}}'}else if(a[3]){d=a[3]=='first'?'previous':'next';f=a[3]=='only'?'previous':'next';c=a[3]=='first'||a[3]=='last';g=a[5]?'&&n.nodeName!==e.nodeName':'&&n.nodeName<"@"';b='if(e!==h){'+('n=e;while((n=n.'+d+'Sibling)'+g+');if(!n){'+(c?b:'n=e;while((n=n.'+f+'Sibling)'+g+');if(!n){'+b+'}')+'}')+'}'}else{i=false}break}return{'source':b,'status':i}});NW.Dom.registerSelector('nwmatcher:dpseudos',/^\:(link|visited|target|lang|not|active|focus|hover|checked|disabled|enabled|selected)(?:\((["']*)(.*?(\(.*\))?[^'"()]*?)\2\))?(.*)/,(function(){var i=document,e=NW.Dom.Config,g=NW.Dom.Tokens,h=RegExp('^'+g.whitespace+'|'+g.whitespace+'$','g'),t=RegExp('^((?!:not)('+g.prefixes+'|'+g.identifier+'|\\([^()]*\\))+|\\['+g.attributes+'\\])$');return function(a,b){var d,f=true,c;switch(a[1]){case'not':d=a[3].replace(h,'');if(e.SIMPLENOT&&!t.test(d)){NW.Dom.emit('Negation pseudo-class only accepts simple selectors "'+a.join('')+'"')}else{if('compatMode'in i){b='if(!'+NW.Dom.compile([d],'',false)+'(e,s,r,d,h,g)){'+b+'}'}else{b='if(!s.match(e, "'+d.replace(/\x22/g,'\\"')+'",g)){'+b+'}'}}break;case'checked':c='if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)';b=(e.USE_HTML5?c+'||(/^option$/i.test(e.nodeName)&&e.selected)':c)+'){'+b+'}';break;case'disabled':b='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&e.disabled){'+b+'}';break;case'enabled':b='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&!e.disabled){'+b+'}';break;case'lang':c='';if(a[3])c=a[3].substr(0,2)+'-';b='do{(n=e.lang||"").toLowerCase();if((n==""&&h.lang=="'+a[3].toLowerCase()+'")||(n&&(n=="'+a[3].toLowerCase()+'"||n.substr(0,3)=="'+c.toLowerCase()+'"))){'+b+'break;}}while((e=e.parentNode)&&e!==g);';break;case'target':n=i.location?i.location.hash:'';if(n){b='if(e.id=="'+n.slice(1)+'"){'+b+'}'}break;case'link':b='if(s.isLink(e)&&!e.visited){'+b+'}';break;case'visited':b='if(s.isLink(e)&&e.visited){'+b+'}';break;case'active':b='if(e===d.activeElement){'+b+'}';break;case'hover':b='if(e===d.hoverElement){'+b+'}';break;case'focus':b='hasFocus'in i?'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href)){'+b+'}':'if(e===d.activeElement&&(e.type||e.href)){'+b+'}';break;case'selected':b='if(e.nodeName.toLowerCase()=="option"&&e.selected){'+b+'}';break;default:f=false;break}return{'source':b,'status':f}}})());
+(function(r){var X='nwmatcher-1.2.4beta',k=typeof exports=='object'?exports:((r.NW||(r.NW={}))&&(r.NW.Dom||(r.NW.Dom={}))),j=r.document,y=j.documentElement,by=[].slice,Y,I,z,J,u,Z,ba,bb,bc,K='[#.:]?',bd='([~*^$|!]?={1})',s='[\\x20\\t\\n\\r\\f]*',be='[\\x20]|[>+~][^>+~]',bf='[-+]?\\d*n?[-+]?\\d*',L='"[^"]*"'+"|'[^']*'",M='\\[.*\\]|\\(.*\\)|\\{.*\\}',m='(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',A='(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',bg='('+L+'|'+A+')',w=s+'('+m+'+:?'+m+'+)'+s+'(?:'+bd+s+bg+')?'+s,bm=w.replace(bg,'([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),B='((?:'+bf+'|'+L+'|'+K+'|'+m+'+|\\['+w+'\\]|\\(.+\\)|'+s+'|,)+)',bn='.+',N='(?=[\\x20\\t\\n\\r\\f]*[^>+~(){}<>])(\\*|(?:'+K+A+')|'+be+'|\\['+w+'\\]|\\('+B+'\\)|\\{'+bn+'\\}|,)+',bo=N.replace(B,'.*'),C=RegExp(N,'g'),O=RegExp('^'+s+'|'+s+'$','g'),P=RegExp('([^,\\\\\\[\\]]+|\\[[^[\\]]*\\]|\\[.*\\]|\\([^()]+\\)|\\(.*\\)|\\{[^{}]+\\}|\\{.*\\}|\\\\.)+','g'),bp=RegExp('(\\['+w+'\\]|\\('+B+'\\)|[^\\x20>+~]|\\\\.)+','g'),bq=/[\x20\t\n\r\f]+/g,br=RegExp(A+'|^$'),v={},x={'=':"n=='%m'",'^=':"n.indexOf('%m')==0",'*=':"n.indexOf('%m')>-1",'|=':"(n+'-').indexOf('%m-')==0",'~=':"(' '+n+' ').indexOf(' %m ')>-1",'$=':"n.substr(n.length-'%m'.length)=='%m'"},D={ID:RegExp('^\\*?#('+m+'+)|'+M),TAG:RegExp('^('+m+'+)|'+M),CLASS:RegExp('^\\*?\\.('+m+'+$)|'+M)},o={universal:/^\*(.*)/,id:RegExp('^#('+m+'+)(.*)'),tagName:RegExp('^('+m+'+)(.*)'),className:RegExp('^\\.('+m+'+)(.*)'),attribute:RegExp('^\\['+bm+'\\](.*)'),children:/^[\x20\t\n\r\f]*\>[\x20\t\n\r\f]*(.*)/,adjacent:/^[\x20\t\n\r\f]*\+[\x20\t\n\r\f]*(.*)/,relative:/^[\x20\t\n\r\f]*\~[\x20\t\n\r\f]*(.*)/,ancestor:/^[\x20\t\n\r\f]+(.*)/},Q,p,bh,bs='getElementsByTagName'in j,bt='getElementsByClassName'in j,bu={value:1,checked:1,selected:1},bi=typeof j.addEventListener!='function',bj='f&&f(c[k]);r[r.length]=c[k];continue main;',bv=bi?'if(e.nodeName<"A")continue;':'',q={CACHING:false,SIMPLENOT:true,USE_HTML5:false,USE_QSAPI:false},configure=function(a){for(var b in a){q[b]=!!a[b];if(b=='SIMPLENOT'){R={};E={};S={};F={};q['USE_QSAPI']=false;C=new RegExp(bo,'g')}else if(b=='USE_QSAPI'){C=new RegExp(N,'g')}}},bw=function(a,b,d){var f=-1,c;while((c=b[++f]))d(a[a.length]=c);return a},l=function(a){if(typeof r.DOMException!=='undefined'){var b=Error();b.message='SYNTAX_ERR: (Selectors) '+a;b.code=12;throw b;}else{throw Error(12,'SYNTAX_ERR: (Selectors) '+a);}},G=function(a,b){var d=j;J=a;j=a.ownerDocument||a;if(b||d!=j){y=j.documentElement;p=j.createElement('DiV').nodeName=='DiV';bh=p?'.toUpperCase()':'';Q=p||typeof j.compatMode=='string'&&j.compatMode.indexOf('CSS')<0;q.CACHING&&k.setCache(true,j)}},T=function(a,b){var d=0,f=null;while((f=b[d])){if(f.getAttribute('id')==a){break}++d}return f},H=!('fileSize'in j)?function(a,b){a=a.replace(/\\/g,'');return b.getElementById&&b.getElementById(a)||T(a,b.getElementsByTagName('*'))}:function(a,b){var d=null;a=a.replace(/\\/g,'');if(p||b.nodeType!=9){return T(a,b.getElementsByTagName('*'))}if((d=b.getElementById(a))&&d.name==a&&b.getElementsByName){return T(a,b.getElementsByName(a))}return d},bx=function(a,b){G(b||(b=j));return H(a,b)},U=function(a,b,d){var f=typeof a=='string'?a.match(P):a;if(f.length==1){b+=(d?'e=c[k];':'e=k;')+bk(f[0],d?bj:'f&&f(k);return true;')}else{var c=-1,i={},e;while((e=f[++c])){e=e.replace(O,'');if(!i[e]&&(i[e]=true)){b+=(c>0?(d?'e=c[k];':'e=k;'):'')+bk(e,d?bj:'f&&f(k);return true;')}}}if(d)return Function('c,s,r,d,h,g,f','var N,n,x=0,k=-1,e;main:while((e=c[++k])){'+b+'}return r;');else return Function('e,s,r,d,h,g,f','var N,n,x=0,k=e;'+b+'return false;')},bk=function(a,b){var d=0,f,c,i,e,g,h;while(a){d++;if((c=a.match(o.universal))){h=''}else if((c=a.match(o.id))){b='if('+(p?'e.getAttribute("id")':'(e.submit?e.getAttribute("id"):e.id)')+'=="'+c[1]+'"){'+b+'}'}else if((c=a.match(o.tagName))){b='if(e.nodeName'+(p?'=="'+c[1]+'"':bh+'=="'+c[1].toUpperCase()+'"')+'){'+b+'}'}else if((c=a.match(o.className))){b='if((n='+(p?'e.getAttribute("class")':'e.className')+')&&n.length&&(" "+'+(Q?'n.toLowerCase()':'n')+'.replace('+bq+'," ")+" ").indexOf(" '+(Q?c[1].toLowerCase():c[1])+' ")>-1){'+b+'}'}else if((c=a.match(o.attribute))){if(c[2]&&!x[c[2]]){l('Unsupported operator in attribute selectors "'+a+'"');return''}if(c[2]&&c[4]&&(h=x[c[2]])){c[4]=c[4].replace(/\\([0-9a-f]{2,2})/,'\\x$1');f='n=(e.getAttribute("'+c[1]+'")+"").toLowerCase();';h=h.replace(/\%m/g,c[4].toLowerCase())}else if(c[2]=='!='||c[2]=='='){f='n=e.getAttribute("'+c[1]+'");';h='n'+c[2]+'="'+c[4]+'"'}else if(!c[2]){if(bu[c[1].toLowerCase()]){g='default'+c[1].charAt(0).toUpperCase()+c[1].slice(1).toLowerCase();f='n=e["'+g+'"];';h='n'}else{f='n=e.getAttributeNode("'+c[1]+'");';h='n&&n.specified'}}else{f='';h='false'}b=f+'if('+h+'){'+b+'}'}else if((c=a.match(o.adjacent))){b='var N'+d+'=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){'+b+'break;}}e=N'+d+';'}else if((c=a.match(o.relative))){b='var N'+d+'=e;e=e.parentNode.firstChild;while(e&&e!=N'+d+'){if(e.nodeName>"@"){'+b+'}e=e.nextSibling;}e=N'+d+';'}else if((c=a.match(o.children))){b='var N'+d+'=e;if(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else if((c=a.match(o.ancestor))){b='var N'+d+'=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else{f=false;e=true;for(f in v){if((c=a.match(v[f].Expression))&&c[1]){i=v[f].Callback(c,b);b=i.source;e=i.status;if(e)break}}if(!e){l('Unknown pseudo-class selector "'+a+'"');return''}if(!f){l('Unknown token in selector "'+a+'"');return''}}if(!c){l('Invalid syntax in selector "'+a+'"');return''}a=c&&c[c.length-1]}return b},V=function(a,b,d,f){var c;if(!(a&&a.nodeName>'@')){l('Invalid element argument');return false}else if(!b||typeof b!='string'){l('Invalid selector argument');return false}else if(J!=d){G(d||(d=a.ownerDocument))}b=b.replace(O,'');q.SHORTCUTS&&(b=NW.Dom.shortcuts(b,a,d));if(Z!=b){if((c=b.match(C))&&c[0]==b){Y=(c=b.match(P)).length<2;Z=b;bb=c}else{l('The string "'+b+'", is not a valid CSS selector');return false}}else c=bb;if(!E[b]||R[b]!==d){E[b]=U(Y?[b]:c,'',false);R[b]=d}return E[b](a,W,[],j,y,d,f)},bl=function(a,b,d){var f,c,i,e,g,h,t=a;if(arguments.length===0){l('Missing required selector parameters');return[]}else if(a===''){l('Empty selector string');return[]}else if(typeof a!='string'){return[]}else if(J!=b){G(b||(b=j))}if(q.CACHING&&(e=k.loadResults(t,b,j,y))){return d?bw([],e,d):e}a=a.replace(O,'');q.SHORTCUTS&&(a=NW.Dom.shortcuts(a,b));if((c=ba!=a)){if((g=a.match(C))&&g[0]==a){I=(g=a.match(P)).length<2;ba=a;bc=g}else{l('The string "'+a+'", is not a valid CSS selector');return[]}}else g=bc;if(b.nodeType==11){e=b.childNodes}else if(I){if(c){g=a.match(bp);h=g[g.length-1];z=h.split(':not')[0];u=a.length-h.length}if((g=z.match(D.ID))&&(h=g[1])){if((i=H(h,b))){if(V(i,a)){d&&d(i);e=[i]}else e=[]}}else if((g=a.match(D.ID))&&(h=g[1])){if((i=H(h,j))){if('#'+h==a){d&&d(i);e=[i]}if(/[>+~]/.test(a)){b=i.parentNode}else{a=a.replace('#'+h,'*');u-=h.length+1;b=i}}else e=[]}if(e){q.CACHING&&k.saveResults(t,b,j,e);return e}if(!p&&bs&&(g=z.match(D.TAG))&&(h=g[1])){if((e=b.getElementsByTagName(h)).length===0)return[];a=a.slice(0,u)+a.slice(u).replace(h,'*')}else if(!p&&bt&&(g=z.match(D.CLASS))&&(h=g[1])){if((e=b.getElementsByClassName(h.replace(/\\/g,''))).length===0)return[];a=a.slice(0,u)+a.slice(u).replace('.'+h,br.test(a.charAt(a.indexOf(h)-1))?'':'*')}}if(!e){if(bi){e=/^(?:applet|object)$/i.test(b.nodeName)?b.childNodes:b.getElementsByTagName('*');bv='if(e.nodeName<"A")continue;'}else{e=b.getElementsByTagName('*')}}if(!F[a]||S[a]!==b){F[a]=U(I?[a]:g,'',true);S[a]=b}e=F[a](e,W,[],j,y,b,d);q.CACHING&&k.saveResults(t,b,j,e);return e},R={},E={},S={},F={},W={byId:H,match:V,select:bl};Tokens={prefixes:K,encoding:m,operators:bd,whitespace:s,identifier:A,attributes:w,combinators:be,pseudoclass:B,pseudoparms:bf,quotedvalue:L};k.emit=l;k.byId=bx;k.match=V;k.select=bl;k.compile=U;k.configure=configure;k.Config=q;k.Operators=x;k.Selectors=v;k.Snapshot=W;k.Tokens=Tokens;k.setCache=function(){return};k.loadResults=function(){return};k.saveResults=function(){return};k.shortcuts=function(a){return a};k.registerOperator=function(a,b){x[a]||(x[a]=b)};k.registerSelector=function(a,b,d){v[a]||(v[a]={Expression:b,Callback:d})};G(j,true)})(this);
+(function(){var i={'a':1,'A':1,'area':1,'AREA':1,'link':1,'LINK':1},e=document.documentElement,g='compareDocumentPosition'in e?function(a,b){return(a.compareDocumentPosition(b)&16)==16}:'contains'in e?function(a,b){return b.nodeType==1&&a.contains(b)}:function(a,b){while((b=b.parentNode)&&b.nodeType==1){if(b===a)return true}return false},h=function(a){return a.getAttribute('href')&&i[a.nodeName]},t=function(a){a=a.firstChild;while(a){if(a.nodeType==3||a.nodeName>'@')return false;a=a.nextSibling}return true},r=function(a,b){var d=1,f=b?'nextSibling':'previousSibling';while((a=a[f])){if(a.nodeName>'@')++d}return d},X=function(a,b){var d=1,f=b?'nextSibling':'previousSibling',c=a.nodeName;while((a=a[f])){if(a.nodeName==c)++d}return d};NW.Dom.Snapshot['contains']=g;NW.Dom.Snapshot['isLink']=h;NW.Dom.Snapshot['isEmpty']=t;NW.Dom.Snapshot['nthOfType']=X;NW.Dom.Snapshot['nthElement']=r})();NW.Dom.registerSelector('nwmatcher:spseudos',/^\:((root|empty|nth-)?(?:(first|last|only)-)?(child)?-?(of-type)?)(?:\(([^\x29]*)\))?(.*)/,function(a,b){var d,f,c,i=true,e,g;switch(a[2]){case'root':if(a[7])b='if(e===h||s.contains(h,e)){'+b+'}';else b='if(e===h){'+b+'}';break;case'empty':b='if(s.isEmpty(e)){'+b+'}';break;default:if(a[2]&&a[6]){if(a[6]=='n'){b='if(e!==h){'+b+'}';break}else if(a[6]=='even'){d=2;c=0}else if(a[6]=='odd'){d=2;c=1}else{c=((f=a[6].match(/(-?\d+)$/))?parseInt(f[1],10):0);d=((f=a[6].match(/(-?\d*)n/))?parseInt(f[1],10):0);if(f&&f[1]=='-')d=-1}e=c<1&&d>1?'(n-('+c+'))%'+d+'==0':d>+1?(a[3]=='last')?'(n-('+c+'))%'+d+'==0':'n>='+c+'&&(n-('+c+'))%'+d+'==0':d<-1?(a[3]=='last')?'(n-('+c+'))%'+d+'==0':'n<='+c+'&&(n-('+c+'))%'+d+'==0':d===0?'n=='+c:(a[3]=='last')?d==-1?'n>='+c:'n<='+c:d==-1?'n<='+c:'n>='+c;b='if(e!==h){n=s['+(a[5]?'"nthOfType"':'"nthElement"')+'](e,'+(a[3]=='last'?'true':'false')+');if('+e+'){'+b+'}}'}else if(a[3]){d=a[3]=='first'?'previous':'next';f=a[3]=='only'?'previous':'next';c=a[3]=='first'||a[3]=='last';g=a[5]?'&&n.nodeName!==e.nodeName':'&&n.nodeName<"@"';b='if(e!==h){'+('n=e;while((n=n.'+d+'Sibling)'+g+');if(!n){'+(c?b:'n=e;while((n=n.'+f+'Sibling)'+g+');if(!n){'+b+'}')+'}')+'}'}else{i=false}break}return{'source':b,'status':i}});NW.Dom.registerSelector('nwmatcher:dpseudos',/^\:(link|visited|target|lang|not|active|focus|hover|checked|disabled|enabled|selected)(?:\((["']*)(.*?(\(.*\))?[^'"()]*?)\2\))?(.*)/,(function(){var i=document,e=NW.Dom.Config,g=NW.Dom.Tokens,h=RegExp('^'+g.whitespace+'|'+g.whitespace+'$','g'),t=RegExp('^((?!:not)('+g.prefixes+'|'+g.identifier+'|\\([^()]*\\))+|\\['+g.attributes+'\\])$');return function(a,b){var d,f=true,c;switch(a[1]){case'not':d=a[3].replace(h,'');if(e.SIMPLENOT&&!t.test(d)){NW.Dom.emit('Negation pseudo-class only accepts simple selectors "'+a.join('')+'"')}else{if('compatMode'in i){b='if(!'+NW.Dom.compile([d],'',false)+'(e,s,r,d,h,g)){'+b+'}'}else{b='if(!s.match(e, "'+d.replace(/\x22/g,'\\"')+'",g)){'+b+'}'}}break;case'checked':c='if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)';b=(e.USE_HTML5?c+'||(/^option$/i.test(e.nodeName)&&e.selected)':c)+'){'+b+'}';break;case'disabled':b='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&e.disabled){'+b+'}';break;case'enabled':b='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&!e.disabled){'+b+'}';break;case'lang':c='';if(a[3])c=a[3].substr(0,2)+'-';b='do{(n=e.lang||"").toLowerCase();if((n==""&&h.lang=="'+a[3].toLowerCase()+'")||(n&&(n=="'+a[3].toLowerCase()+'"||n.substr(0,3)=="'+c.toLowerCase()+'"))){'+b+'break;}}while((e=e.parentNode)&&e!==g);';break;case'target':n=i.location?i.location.hash:'';if(n){b='if(e.id=="'+n.slice(1)+'"){'+b+'}'}break;case'link':b='if(s.isLink(e)&&!e.visited){'+b+'}';break;case'visited':b='if(s.isLink(e)&&e.visited){'+b+'}';break;case'active':b='if(e===d.activeElement){'+b+'}';break;case'hover':b='if(e===d.hoverElement){'+b+'}';break;case'focus':b='hasFocus'in i?'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href)){'+b+'}':'if(e===d.activeElement&&(e.type||e.href)){'+b+'}';break;case'selected':b='if(e.nodeName.toLowerCase()=="option"&&e.selected){'+b+'}';break;default:f=false;break}return{'source':b,'status':f}}})());
View
2 src/nwmatcher-base.js
@@ -75,7 +75,7 @@
'|\\[' + attributes + '\\]' +
'|\\(' + pseudoclass + '\\)' +
'|\\{' + extensions + '\\}' +
- '|,.' +
+ '|,' +
')+',
extendedValidator = standardValidator.replace(pseudoclass, '.*'),
View
2 src/nwmatcher.js
@@ -132,7 +132,7 @@
// dom properties selector (extension)
'|\\{' + extensions + '\\}' +
// selector group separator (comma)
- '|,.' +
+ '|,' +
// close match group
')+',

0 comments on commit 3511226

Please sign in to comment.
Something went wrong with that request. Please try again.