nwmatcher
Advanced tools
Comparing version 1.2.5 to 1.3.0
{ | ||
"name": "nwmatcher", | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"description": "A CSS3-compliant JavaScript selector engine.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://javascript.nwbox.com/NWMatcher/", |
@@ -21,23 +21,14 @@ /* | ||
'jquery:child', | ||
/^\:(even|odd|eq|lt|gt|first|last|nth)(?:\(([^()]*)\))?(.*)/, | ||
function(match, source) { | ||
/^\:((?:(nth|eq|lt|gt)\(([^()]*)\))|(?:even|odd|first|last))(.*)/i, | ||
function(match, source, selector) { | ||
var status = true, ACCEPT_NODE = NW.Dom.ACCEPT_NODE; | ||
switch (match[1]) { | ||
case 'even': | ||
source = source.replace(ACCEPT_NODE, 'if((x=x^1)==1){' + ACCEPT_NODE + '}'); | ||
break; | ||
switch (match[1].toLowerCase()) { | ||
case 'odd': | ||
source = source.replace(ACCEPT_NODE, 'if((x=x^1)==0){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'eq': | ||
source = source.replace(ACCEPT_NODE, 'if(x++==' + match[2] + '){' + ACCEPT_NODE + '}'); | ||
case 'even': | ||
source = source.replace(ACCEPT_NODE, 'if((x=x^1)==1){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'lt': | ||
source = source.replace(ACCEPT_NODE, 'if(x++<' + match[2] + '){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'gt': | ||
source = source.replace(ACCEPT_NODE, 'if(x++>' + match[2] + '){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'first': | ||
@@ -49,8 +40,21 @@ source = 'n=h.getElementsByTagName(e.nodeName);if(n.length&&n[0]===e){' + source + '}'; | ||
break; | ||
case 'nth': | ||
source = 'n=h.getElementsByTagName(e.nodeName);if(n.length&&n[' + match[2] + ']===e){' + source + '}'; | ||
default: | ||
switch (match[2].toLowerCase()) { | ||
case 'nth': | ||
source = 'n=h.getElementsByTagName(e.nodeName);if(n.length&&n[' + match[3] + ']===e){' + source + '}'; | ||
break; | ||
case 'eq': | ||
source = source.replace(ACCEPT_NODE, 'if(x++==' + match[3] + '){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'lt': | ||
source = source.replace(ACCEPT_NODE, 'if(x++<' + match[3] + '){' + ACCEPT_NODE + '}'); | ||
break; | ||
case 'gt': | ||
source = source.replace(ACCEPT_NODE, 'if(x++>' + match[3] + '){' + ACCEPT_NODE + '}'); | ||
break; | ||
default: | ||
status = false; | ||
break; | ||
} | ||
break; | ||
default: | ||
status = false; | ||
break; | ||
} | ||
@@ -70,3 +74,3 @@ | ||
'jquery:pseudo', | ||
/^\:(has|checkbox|file|image|password|radio|reset|submit|text|button|input|header|hidden|visible|parent)(?:\((["']*)([^'"()]*)\2\))?(.*)/, | ||
/^\:(has|checkbox|file|image|password|radio|reset|submit|text|button|input|header|hidden|visible|parent)(?:\(\s*(["']*)?([^'"()]*)\2\s*\))?(.*)/i, | ||
function(match, source) { | ||
@@ -76,5 +80,5 @@ | ||
switch(match[1]) { | ||
switch(match[1].toLowerCase()) { | ||
case 'has': | ||
source = source.replace(ACCEPT_NODE, 'if(e.getElementsByTagName("' + match[3] + '")[0]){' + ACCEPT_NODE + '}'); | ||
source = source.replace(ACCEPT_NODE, 'if(e.getElementsByTagName("' + match[3].replace(/^\s|\s$/g, '') + '")[0]){' + ACCEPT_NODE + '}'); | ||
break; | ||
@@ -89,4 +93,4 @@ case 'checkbox': | ||
case 'text': | ||
// :checkbox, :file, :image, :password, :radio, :reset, :submit, :text, ... ;-) | ||
source = 'if(e.type&&e.type=="' + match[1] + '"){' + source + '}'; | ||
// :checkbox, :file, :image, :password, :radio, :reset, :submit, :text ... | ||
source = 'if(e.type&&e.getAttribute("type")=="' + match[1] + '"){' + source + '}'; | ||
break; | ||
@@ -93,0 +97,0 @@ case 'button': |
@@ -87,2 +87,3 @@ /* | ||
NW.Dom.Snapshot['nthElement'] = nthElement; | ||
})(); | ||
@@ -92,3 +93,3 @@ | ||
'nwmatcher:spseudos', | ||
/^\:((root|empty|nth-)?(?:(first|last|only)-)?(child)?-?(of-type)?)(?:\(([^\x29]*)\))?(.*)/, | ||
/^\:(root|empty|(?:first|last|only)(?:-child|-of-type)|nth(?:-last)?(?:-child|-of-type)\(\s*(even|odd|(?:[-+]{0,1}\d*n\s*)?[-+]{0,1}\s*\d*)\s*\))?(.*)/i, | ||
function(match, source) { | ||
@@ -98,6 +99,6 @@ | ||
switch (match[2]) { | ||
switch (match[1]) { | ||
case 'root': | ||
if (match[7]) | ||
if (match[3]) | ||
source = 'if(e===h||s.contains(h,e)){' + source + '}'; | ||
@@ -113,40 +114,40 @@ else | ||
default: | ||
if (match[2] && match[6]) { | ||
if (match[1] && match[2]) { | ||
if (match[6] == 'n') { | ||
if (match[2] == 'n') { | ||
source = 'if(e!==h){' + source + '}'; | ||
break; | ||
} else if (match[6] == 'even') { | ||
} else if (match[2] == 'even') { | ||
a = 2; | ||
b = 0; | ||
} else if (match[6] == 'odd') { | ||
} else if (match[2] == 'odd') { | ||
a = 2; | ||
b = 1; | ||
} else { | ||
b = ((n = match[6].match(/(-?\d+)$/)) ? parseInt(n[1], 10) : 0); | ||
a = ((n = match[6].match(/(-?\d*)n/)) ? parseInt(n[1], 10) : 0); | ||
b = ((n = match[2].match(/(-?\d+)$/)) ? parseInt(n[1], 10) : 0); | ||
a = ((n = match[2].match(/(-?\d*)n/i)) ? parseInt(n[1], 10) : 0); | ||
if (n && n[1] == '-') a = -1; | ||
} | ||
test = b < 1 && a > 1 ? '(n-(' + b + '))%' + a + '==0' : a > +1 ? | ||
(match[3] == 'last') ? '(n-(' + b + '))%' + a + '==0' : | ||
'n>=' + b + '&&(n-(' + b + '))%' + a + '==0' : a < -1 ? | ||
(match[3] == 'last') ? '(n-(' + b + '))%' + a + '==0' : | ||
'n<=' + b + '&&(n-(' + b + '))%' + a + '==0' : a=== 0 ? | ||
test = a > 1 ? | ||
(/last/i.test(match[1])) ? '(n-(' + b + '))%' + a + '==0' : | ||
'n>=' + b + '&&(n-(' + b + '))%' + a + '==0' : a < -1 ? | ||
(/last/i.test(match[1])) ? '(n-(' + b + '))%' + a + '==0' : | ||
'n<=' + b + '&&(n-(' + b + '))%' + a + '==0' : a=== 0 ? | ||
'n==' + b : | ||
(match[3] == 'last') ? | ||
a == -1 ? 'n>=' + b : 'n<=' + b : | ||
a == -1 ? 'n<=' + b : 'n>=' + b; | ||
(/last/i.test(match[1])) ? | ||
a == -1 ? 'n>=' + b : 'n<=' + b : | ||
a == -1 ? 'n<=' + b : 'n>=' + b; | ||
source = | ||
'if(e!==h){' + | ||
'n=s[' + (match[5] ? '"nthOfType"' : '"nthElement"') + ']' + | ||
'(e,' + (match[3] == 'last' ? 'true' : 'false') + ');' + | ||
'n=s[' + (/-of-type/i.test(match[1]) ? '"nthOfType"' : '"nthElement"') + ']' + | ||
'(e,' + (/last/i.test(match[1]) ? 'true' : 'false') + ');' + | ||
'if(' + test + '){' + source + '}' + | ||
'}'; | ||
} else if (match[3]) { | ||
} else if (match[1]) { | ||
a = match[3] == 'first' ? 'previous' : 'next'; | ||
n = match[3] == 'only' ? 'previous' : 'next'; | ||
b = match[3] == 'first' || match[3] == 'last'; | ||
type = match[5] ? '&&n.nodeName!==e.nodeName' : '&&n.nodeName<"@"'; | ||
a = /first/i.test(match[1]) ? 'previous' : 'next'; | ||
n = /only/i.test(match[1]) ? 'previous' : 'next'; | ||
b = /first|last/i.test(match[1]); | ||
type = /-of-type/i.test(match[1]) ? '&&n.nodeName!==e.nodeName' : '&&n.nodeName<"@"'; | ||
source = 'if(e!==h){' + | ||
@@ -168,2 +169,3 @@ ( 'n=e;while((n=n.' + a + 'Sibling)' + type + ');if(!n){' + (b ? source : | ||
}; | ||
}); | ||
@@ -173,3 +175,3 @@ | ||
'nwmatcher:dpseudos', | ||
/^\:(link|visited|target|lang|not|active|focus|hover|checked|disabled|enabled|selected)(?:\((["']*)(.*?(\(.*\))?[^'"()]*?)\2\))?(.*)/, | ||
/^\:(link|visited|target|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(([^()]*|.*)\))?(.*)/i, | ||
(function() { | ||
@@ -181,5 +183,3 @@ | ||
reTrimSpace = RegExp( | ||
'^' + Tokens.whitespace + | ||
'|' + Tokens.whitespace + '$', 'g'), | ||
reTrimSpace = RegExp('^\\s+|\\s+$', 'g'), | ||
@@ -194,3 +194,3 @@ reSimpleNot = RegExp('^((?!:not)' + | ||
switch (match[1]) { | ||
switch (match[1].match(/^\w+/)[0]) { | ||
@@ -203,3 +203,3 @@ case 'not': | ||
if ('compatMode' in doc) { | ||
source = 'if(!' + NW.Dom.compile([ expr ], '', false) + '(e,s,r,d,h,g)){' + source + '}'; | ||
source = 'if(!' + NW.Dom.compile(expr, '', false) + '(e,s,r,d,h,g)){' + source + '}'; | ||
} else { | ||
@@ -212,12 +212,17 @@ source = 'if(!s.match(e, "' + expr.replace(/\x22/g, '\\"') + '",g)){' + source +'}'; | ||
case 'checked': | ||
test = 'if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)'; | ||
source = (Config.USE_HTML5 ? test + '||(/^option$/i.test(e.nodeName)&&e.selected)' : test) + '){' + source + '}'; | ||
source = 'if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)' + | ||
(Config.USE_HTML5 ? '||(/^option$/i.test(e.nodeName)&&(e.selected||e.checked))' : '') + | ||
'){' + source + '}'; | ||
break; | ||
case 'disabled': | ||
source = 'if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&e.disabled){' + source + '}'; | ||
source = 'if(((typeof e.form!=="undefined"' + | ||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') + | ||
')||s.isLink(e))&&e.disabled===true){' + source + '}'; | ||
break; | ||
case 'enabled': | ||
source = 'if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&!e.disabled){' + source + '}'; | ||
source = 'if(((typeof e.form!=="undefined"' + | ||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') + | ||
')||s.isLink(e))&&e.disabled===false){' + source + '}'; | ||
break; | ||
@@ -227,6 +232,6 @@ | ||
test = ''; | ||
if (match[3]) test = match[3].substr(0, 2) + '-'; | ||
if (match[2]) test = match[2].substr(0, 2) + '-'; | ||
source = 'do{(n=e.lang||"").toLowerCase();' + | ||
'if((n==""&&h.lang=="' + match[3].toLowerCase() + '")||' + | ||
'(n&&(n=="' + match[3].toLowerCase() + | ||
'if((n==""&&h.lang=="' + match[2].toLowerCase() + '")||' + | ||
'(n&&(n=="' + match[2].toLowerCase() + | ||
'"||n.substr(0,3)=="' + test.toLowerCase() + '")))' + | ||
@@ -261,3 +266,3 @@ '{' + source + 'break;}}while((e=e.parentNode)&&e!==g);'; | ||
source = 'hasFocus' in doc ? | ||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href)){' + source + '}' : | ||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href||!isNaN(e.tabIndex))){' + source + '}' : | ||
'if(e===d.activeElement&&(e.type||e.href)){' + source + '}'; | ||
@@ -267,3 +272,3 @@ break; | ||
case 'selected': | ||
source = 'if(e.nodeName.toLowerCase()=="option"&&e.selected){' + source + '}'; | ||
source = 'if(/^option$/i.test(e.nodeName)&&(e.selected||e.checked)){' + source + '}'; | ||
break; | ||
@@ -282,2 +287,3 @@ | ||
}; | ||
})()); |
/*! | ||
* NWMatcher 1.2.5 - Fast CSS3 Selector Engine | ||
* NWMatcher 1.3.0 - Fast CSS3 Selector Engine | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* See http://nwbox.com/license | ||
*/ | ||
(function(n){var bB='nwmatcher-1.2.5',g=typeof exports=='object'?exports:((n.NW||(n.NW={}))&&(n.NW.Dom||(n.NW.Dom={}))),i=n.document,x=i.documentElement,bC=[].slice,Z,I,y,J,t,ba,bb,bc,bd,K='[#.:]?',be='([~*^$|!]?={1})',r='[\\x20\\t\\n\\r\\f]*',bf='[\\x20]|[>+~][^>+~]',bg='[-+]?\\d*n?[-+]?\\d*',L='"[^"]*"'+"|'[^']*'",M='\\[.*\\]|\\(.*\\)|\\{.*\\}',o='(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',z='(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',bh='('+L+'|'+z+')',v=r+'('+o+'+:?'+o+'+)'+r+'(?:'+be+r+bh+')?'+r,bj=v.replace(bh,'([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),A='((?:'+bg+'|'+L+'|'+K+'|'+o+'+|\\['+v+'\\]|\\(.+\\)|'+r+'|,)+)',bk='.+',N='(?=[\\x20\\t\\n\\r\\f]*[^>+~(){}<>])(\\*|(?:'+K+z+')|'+bf+'|\\['+v+'\\]|\\('+A+'\\)|\\{'+bk+'\\}|,)+',bl=N.replace(A,'.*'),B=RegExp(N,'g'),O=RegExp('^'+r+'|'+r+'$','g'),P=RegExp('([^,\\\\\\[\\]]+|\\[[^[\\]]*\\]|\\[.*\\]|\\([^()]+\\)|\\(.*\\)|\\{[^{}]+\\}|\\{.*\\}|\\\\.)+','g'),bm=RegExp('(\\['+v+'\\]|\\('+A+'\\)|[^\\x20>+~]|\\\\.)+','g'),bn=/[\x20\t\n\r\f]+/g,bo=RegExp(z+'|^$'),bp={action:2,cite:2,codebase:2,data:2,href:2,longdesc:2,lowsrc:2,src:2,usemap:2},u={},w={'=':"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'"},C={ID:RegExp('^\\*?#('+o+'+)|'+M),TAG:RegExp('^('+o+'+)|'+M),CLASS:RegExp('^\\*?\\.('+o+'+$)|'+M)},q={universal:/^\*(.*)/,id:RegExp('^#('+o+'+)(.*)'),tagName:RegExp('^('+o+'+)(.*)'),className:RegExp('^\\.('+o+'+)(.*)'),attribute:RegExp('^\\['+bj+'\\](.*)'),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,s,bq='getElementsByTagName'in i,br='getElementsByClassName'in i,D=typeof i.addEventListener!='function',bs={'href':1,'lang':1,'src':1,'style':1,'title':1,'type':1,'xmlns':1,'xml:lang':1,'xml:space':1},bt={'value':1,'checked':1,'selected':1},bu=D?'.toUpperCase()':'',R='r[r.length]=c[k];if(f&&false===f(c[k]))break;else continue main;',bv=D?'if(e.nodeName<"A")continue;':'',p={CACHING:false,SIMPLENOT:true,USE_HTML5:false,USE_QSAPI:false,VERBOSITY:true},bw=function(a){for(var b in a){p[b]=!!a[b];if(b=='SIMPLENOT'){S={};E={};T={};F={};p['USE_QSAPI']=false;B=RegExp(bl,'g')}else if(b=='USE_QSAPI'){B=RegExp(N,'g')}}},bx=function(a,b,d){var f=-1,c;while((c=b[++f])){if(false===d(a[a.length]=c)){break}}return a},l=function(a){a='SYNTAX_ERR: '+a+' ';if(p.VERBOSITY){if(typeof n.DOMException!='undefined'){throw{code:12,message:a}}else{throw new Error(12,a);}}else{if(n.console&&n.console.log){n.console.log(a)}else{n.status+=a}}},G=function(b,d){var f=i;J=b;i=b.ownerDocument||b;if(d||f!==i){x=i.documentElement;s=i.createElement('DiV').nodeName=='DiV';Q=!s&&typeof i.compatMode=='string'?i.compatMode.indexOf('CSS')<0:(function(){var a=document.createElement('div').style;return a&&(a.width=1)&&a.width=='1px'})();p.CACHING&&g.setCache(true,i)}},U=function(a,b){var d=0,f=null;while((f=b[d])){if(f.getAttribute('id')==a){break}++d}return f},H=!('fileSize'in i)?function(a,b){a=a.replace(/\\/g,'');return b.getElementById&&b.getElementById(a)||U(a,b.getElementsByTagName('*'))}:function(a,b){var d=null;a=a.replace(/\\/g,'');if(s||b.nodeType!=9){return U(a,b.getElementsByTagName('*'))}if((d=b.getElementById(a))&&d.name==a&&b.getElementsByName){return U(a,b.getElementsByName(a))}return d},by=function(a,b){G(b||(b=i));return H(a,b)},bz=function(a,b){return(bp[b]?a.getAttribute(b,2)||'':((a=a.attributes[b])&&a.value)||'')},V=function(a,b,d){var f=typeof a=='string'?a.match(P):a;typeof b=='string'||(b='');if(f.length==1){b+=bi(f[0],d?R:'f&&f(k);return true;')}else{var c=-1,k={},e;while((e=f[++c])){e=e.replace(O,'');if(!k[e]&&(k[e]=true)){b+=bi(e,d?R:'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;')},bi=function(a,b){var d=0,f,c,k,e,j,h,m;while(a){d++;if((c=a.match(q.universal))){f=''}else if((c=a.match(q.id))){b='if('+(s?'s.getAttr(e,"id")':'(e.submit?s.getAttr(e,"id"):e.id)')+'=="'+c[1]+'"){'+b+'}'}else if((c=a.match(q.tagName))){b='if(e.nodeName'+(s?'=="'+c[1]+'"':bu+'=="'+c[1].toUpperCase()+'"')+'){'+b+'}'}else if((c=a.match(q.className))){b='if((n='+(s?'e.getAttribute("class")':'e.className')+')&&n.length&&(" "+'+(Q?'n.toLowerCase()':'n')+'.replace('+bn+'," ")+" ").indexOf(" '+(Q?c[1].toLowerCase():c[1])+' ")>-1){'+b+'}'}else if((c=a.match(q.attribute))){if(c[2]&&!w[c[2]]){l('Unsupported operator in attribute selectors "'+a+'"');return''}k=c[1].toLowerCase();if(c[2]&&c[4]&&(m=w[c[2]])){h=k in bs;c[4]=c[4].replace(/\\([0-9a-f]{2,2})/,'\\x$1');m=m.replace(/\%m/g,h?c[4].toLowerCase():c[4]);f='n=s.getAttr(e,"'+k+'")'+(h?'.toLowerCase()':'')+';'}else if(!c[2]){if(bt[k]){h='default'+k.charAt(0).toUpperCase()+k.slice(1);f='n=e["'+h+'"];';m='n'}else{f='n=e.attributes["'+k+'"];';m=D?'n&&n.specified':'n'}}else if(c[2]=='!='||c[2]=='='){f='n=e.attributes["'+k+'"];';m='n&&n.value'+c[2]+'="'+c[4]+'"'}else{f='';m='false'}b=f+'if('+m+'){'+b+'}'}else if((c=a.match(q.adjacent))){b='var N'+d+'=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){'+b+'break;}}e=N'+d+';'}else if((c=a.match(q.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(q.children))){b='var N'+d+'=e;if(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else if((c=a.match(q.ancestor))){b='var N'+d+'=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){'+b+'}e=N'+d+';'}else{f=false;j=true;for(f in u){if((c=a.match(u[f].Expression))&&c[1]){e=u[f].Callback(c,b);b=e.source;j=e.status;if(j)break}}if(!j){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},W=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,'');p.SHORTCUTS&&(b=NW.Dom.shortcuts(b,a,d));if(ba!=b){if((c=b.match(B))&&c[0]==b){Z=(c=b.match(P)).length<2;ba=b;bc=c}else{l('The string "'+b+'", is not a valid CSS selector');return false}}else c=bc;if(!E[b]||S[b]!==d){E[b]=V(Z?[b]:c,'',false);S[b]=d}return E[b](a,X,[],i,x,d,f)},bA=function(a,b){return Y(a,b,function(){return false})[0]||null},Y=function(a,b,d){var f,c,k,e,j,h,m=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(b&&!(/1|9|11/).test(b.nodeType)){l('Invalid context element');return[]}else if(J!==b){G(b||(b=i))}if(p.CACHING&&(e=g.loadResults(m,b,i,x))){return d?bx([],e,d):e}a=a.replace(O,'');p.SHORTCUTS&&(a=NW.Dom.shortcuts(a,b));if((c=bb!=a)){if((j=a.match(B))&&j[0]==a){I=(j=a.match(P)).length<2;bb=a;bd=j}else{l('The string "'+a+'", is not a valid CSS selector');return[]}}else j=bd;if(b.nodeType==11){e=b.childNodes}else if(I){if(c){j=a.match(bm);h=j[j.length-1];y=h.split(':not')[0];t=a.length-h.length}if((j=y.match(C.ID))&&(h=j[1])){if((k=H(h,b))){if(W(k,a)){d&&d(k);e=[k]}else e=[]}}else if((j=a.match(C.ID))&&(h=j[1])){if((k=H(h,i))){if('#'+h==a){d&&d(k);e=[k]}if(/[>+~]/.test(a)){b=k.parentNode}else{a=a.replace('#'+h,'*');t-=h.length+1;b=k}}else e=[]}if(e){p.CACHING&&g.saveResults(m,b,i,e);return e}if(!s&&bq&&(j=y.match(C.TAG))&&(h=j[1])){if((e=b.getElementsByTagName(h)).length===0)return[];a=a.slice(0,t)+a.slice(t).replace(h,'*')}else if(!s&&br&&(j=y.match(C.CLASS))&&(h=j[1])){if((e=b.getElementsByClassName(h.replace(/\\/g,''))).length===0)return[];a=a.slice(0,t)+a.slice(t).replace('.'+h,bo.test(a.charAt(a.indexOf(h)-1))?'':'*')}}if(!e){if(D){e=/^(?:applet|object)$/i.test(b.nodeName)?b.childNodes:b.all}else{e=b.getElementsByTagName('*')}}if(!F[a]||T[a]!==b){F[a]=V(I?[a]:j,bv,true);T[a]=b}e=F[a](e,X,[],i,x,b,d);p.CACHING&&g.saveResults(m,b,i,e);return e},S={},E={},T={},F={},X={byId:H,match:W,select:Y,getAttr:bz};Tokens={prefixes:K,encoding:o,operators:be,whitespace:r,identifier:z,attributes:v,combinators:bf,pseudoclass:A,pseudoparms:bg,quotedvalue:L};g.ACCEPT_NODE=R;g.emit=l;g.byId=by;g.match=W;g.first=bA;g.select=Y;g.compile=V;g.configure=bw;g.Config=p;g.Operators=w;g.Selectors=u;g.Snapshot=X;g.Tokens=Tokens;g.setCache=function(){return};g.loadResults=function(){return};g.saveResults=function(){return};g.shortcuts=function(a){return a};g.registerOperator=function(a,b){w[a]||(w[a]=b)};g.registerSelector=function(a,b,d){u[a]||(u[a]={Expression:b,Callback:d})};G(i,true)})(this); | ||
(function(){var g={'a':1,'A':1,'area':1,'AREA':1,'link':1,'LINK':1},h=document.documentElement,f='compareDocumentPosition'in h?function(b,a){return(b.compareDocumentPosition(a)&16)==16}:'contains'in h?function(b,a){return a.nodeType==1&&b.contains(a)}:function(b,a){while((a=a.parentNode)&&a.nodeType==1){if(a===b)return true}return false},i=function(b){return b.getAttribute('href')&&g[b.nodeName]},j=function(b){b=b.firstChild;while(b){if(b.nodeType==3||b.nodeName>'@')return false;b=b.nextSibling}return true},k=function(b,a){var c=1,e=a?'nextSibling':'previousSibling';while((b=b[e])){if(b.nodeName>'@')++c}return c},l=function(b,a){var c=1,e=a?'nextSibling':'previousSibling',d=b.nodeName;while((b=b[e])){if(b.nodeName==d)++c}return c};NW.Dom.Snapshot['contains']=f;NW.Dom.Snapshot['isLink']=i;NW.Dom.Snapshot['isEmpty']=j;NW.Dom.Snapshot['nthOfType']=l;NW.Dom.Snapshot['nthElement']=k})();NW.Dom.registerSelector('nwmatcher:spseudos',/^\:((root|empty|nth-)?(?:(first|last|only)-)?(child)?-?(of-type)?)(?:\(([^\x29]*)\))?(.*)/,function(b,a){var c,e,d,g=true,h,f;switch(b[2]){case'root':if(b[7])a='if(e===h||s.contains(h,e)){'+a+'}';else a='if(e===h){'+a+'}';break;case'empty':a='if(s.isEmpty(e)){'+a+'}';break;default:if(b[2]&&b[6]){if(b[6]=='n'){a='if(e!==h){'+a+'}';break}else if(b[6]=='even'){c=2;d=0}else if(b[6]=='odd'){c=2;d=1}else{d=((e=b[6].match(/(-?\d+)$/))?parseInt(e[1],10):0);c=((e=b[6].match(/(-?\d*)n/))?parseInt(e[1],10):0);if(e&&e[1]=='-')c=-1}h=d<1&&c>1?'(n-('+d+'))%'+c+'==0':c>+1?(b[3]=='last')?'(n-('+d+'))%'+c+'==0':'n>='+d+'&&(n-('+d+'))%'+c+'==0':c<-1?(b[3]=='last')?'(n-('+d+'))%'+c+'==0':'n<='+d+'&&(n-('+d+'))%'+c+'==0':c===0?'n=='+d:(b[3]=='last')?c==-1?'n>='+d:'n<='+d:c==-1?'n<='+d:'n>='+d;a='if(e!==h){n=s['+(b[5]?'"nthOfType"':'"nthElement"')+'](e,'+(b[3]=='last'?'true':'false')+');if('+h+'){'+a+'}}'}else if(b[3]){c=b[3]=='first'?'previous':'next';e=b[3]=='only'?'previous':'next';d=b[3]=='first'||b[3]=='last';f=b[5]?'&&n.nodeName!==e.nodeName':'&&n.nodeName<"@"';a='if(e!==h){'+('n=e;while((n=n.'+c+'Sibling)'+f+');if(!n){'+(d?a:'n=e;while((n=n.'+e+'Sibling)'+f+');if(!n){'+a+'}')+'}')+'}'}else{g=false}break}return{'source':a,'status':g}});NW.Dom.registerSelector('nwmatcher:dpseudos',/^\:(link|visited|target|lang|not|active|focus|hover|checked|disabled|enabled|selected)(?:\((["']*)(.*?(\(.*\))?[^'"()]*?)\2\))?(.*)/,(function(){var g=document,h=NW.Dom.Config,f=NW.Dom.Tokens,i=RegExp('^'+f.whitespace+'|'+f.whitespace+'$','g'),j=RegExp('^((?!:not)('+f.prefixes+'|'+f.identifier+'|\\([^()]*\\))+|\\['+f.attributes+'\\])$');return function(b,a){var c,e=true,d;switch(b[1]){case'not':c=b[3].replace(i,'');if(h.SIMPLENOT&&!j.test(c)){NW.Dom.emit('Negation pseudo-class only accepts simple selectors "'+b.join('')+'"')}else{if('compatMode'in g){a='if(!'+NW.Dom.compile([c],'',false)+'(e,s,r,d,h,g)){'+a+'}'}else{a='if(!s.match(e, "'+c.replace(/\x22/g,'\\"')+'",g)){'+a+'}'}}break;case'checked':d='if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)';a=(h.USE_HTML5?d+'||(/^option$/i.test(e.nodeName)&&e.selected)':d)+'){'+a+'}';break;case'disabled':a='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&e.disabled){'+a+'}';break;case'enabled':a='if(((typeof e.form!=="undefined"&&!(/hidden/i).test(e.type))||s.isLink(e))&&!e.disabled){'+a+'}';break;case'lang':d='';if(b[3])d=b[3].substr(0,2)+'-';a='do{(n=e.lang||"").toLowerCase();if((n==""&&h.lang=="'+b[3].toLowerCase()+'")||(n&&(n=="'+b[3].toLowerCase()+'"||n.substr(0,3)=="'+d.toLowerCase()+'"))){'+a+'break;}}while((e=e.parentNode)&&e!==g);';break;case'target':n=g.location?g.location.hash:'';if(n){a='if(e.id=="'+n.slice(1)+'"){'+a+'}'}break;case'link':a='if(s.isLink(e)&&!e.visited){'+a+'}';break;case'visited':a='if(s.isLink(e)&&e.visited){'+a+'}';break;case'active':a='if(e===d.activeElement){'+a+'}';break;case'hover':a='if(e===d.hoverElement){'+a+'}';break;case'focus':a='hasFocus'in g?'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href)){'+a+'}':'if(e===d.activeElement&&(e.type||e.href)){'+a+'}';break;case'selected':a='if(e.nodeName.toLowerCase()=="option"&&e.selected){'+a+'}';break;default:e=false;break}return{'source':a,'status':e}}})()); | ||
(function(d,e){if(typeof module==='object'&&typeof exports==='object'){module.exports=function(b){var a={};e(b,a);return a}}else{if(!d.NW){d.NW={}}if(!d.NW.Dom){d.NW.Dom={}}e(d,d.NW.Dom)}})(this,function(x,bn){var bH='nwmatcher-1.3.0',g=bn,i=x.document,t=i.documentElement,bI=[].slice,bc,J,y,z,u,bd,be,bf,bg,K='[#.:]?',bh='([~*^$|!]?={1})',p='[\\x20\\t\\n\\r\\f]*',bi='[\\x20]|[>+~][^>+~]',bj='(?:[-+]?\\d*n)?[-+]?\\d*',L='"[^"]*"'+"|'[^']*'",M='\\[.*\\]|\\(.*\\)|\\{.*\\}',n='(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',A='(?:-?[_0-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',bk='('+L+'|'+A+')',v=p+'('+n+'+:?'+n+'+)'+p+'(?:'+bh+p+bk+')?'+p,bo=v.replace(bk,'([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),B='((?:'+bj+'|'+L+'|'+K+'|'+n+'+|\\['+v+'\\]|\\(.+\\)|'+p+'|,)+)',bp='.+',N='(?=[\\x20\\t\\n\\r\\f]*[^>+~(){}<>])(\\*|(?:'+K+A+')|'+bi+'|\\['+v+'\\]|\\('+B+'\\)|\\{'+bp+'\\}|(?:,|'+p+'))+',bq=N.replace(B,'.*'),O=RegExp(N,'g'),P=RegExp('^'+p+'|'+p+'$','g'),Q=RegExp('([^,\\\\()[\\]]+|\\[[^[\\]]*\\]|\\[.*\\]|\\([^()]+\\)|\\(.*\\)|\\{[^{}]+\\}|\\{.*\\}|\\\\.)+','g'),br=RegExp('(\\['+v+'\\]|\\('+B+'\\)|[^\\x20\\t\\n\\r\\f>+~]|\\\\.)+','g'),bs=/[\x20\t\n\r\f]+/g,bt=RegExp(A+'|^$'),bu={checked:1,disabled:1,ismap:1,multiple:1,readonly:1,selected:1},bl={value:'defaultValue',checked:'defaultChecked',selected:'defaultSelected'},bv={action:2,cite:2,codebase:2,data:2,href:2,longdesc:2,lowsrc:2,src:2,usemap:2},s={},w={'=':"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'"},C={ID:RegExp('^\\*?#('+n+'+)|'+M),TAG:RegExp('^('+n+'+)|'+M),CLASS:RegExp('^\\*?\\.('+n+'+$)|'+M)},q={universal:/^\*(.*)/,id:RegExp('^#('+n+'+)(.*)'),tagName:RegExp('^('+n+'+)(.*)'),className:RegExp('^\\.('+n+'+)(.*)'),attribute:RegExp('^\\['+bo+'\\](.*)'),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]+(.*)/},R,r,bw='getElementsByTagName'in i,bx='getElementsByClassName'in i,S=typeof i.addEventListener!='function',by={'href':1,'lang':1,'src':1,'style':1,'title':1,'type':1,'xmlns':1,'xml:lang':1,'xml:space':1},bz=S?'.toUpperCase()':'',T='r[r.length]=c[k];if(f&&false===f(c[k]))break main;else continue main;',bA=S?'if(e.nodeName<"A")continue;':'',l={CACHING:false,SIMPLENOT:true,UNIQUE_ID:true,USE_HTML5:true,VERBOSITY:true},bB=function(b){if(typeof b=='string'){return l[b]}if(typeof b!='object'){return false}for(var a in b){l[a]=!!b[a];if(a=='SIMPLENOT'){U={};D={};V={};E={}}}O=RegExp(l.SIMPLENOT?N:bq,'g');return true},bC=function(b,a,d){var e=-1,h;while((h=a[++e])){if(false===d(b[b.length]=h)){break}}return b},m=function(b){if(l.VERBOSITY){throw Error(b);}if(x.console&&x.console.log){x.console.log(b)}},F=function(a,d){var e=i;z=a;i=a.ownerDocument||a;if(d||e!==i){t=i.documentElement;r=i.createElement('DiV').nodeName=='DiV';R=!r&&typeof i.compatMode=='string'?i.compatMode.indexOf('CSS')<0:(function(){var b=document.createElement('div').style;return b&&(b.width=1)&&b.width=='1px'})();l.CACHING&&g.setCache(true,i)}},W=function(b,a){var d=0,e=null;while((e=a[d])){if(e.getAttribute('id')==b){break}++d}return e},G=!('fileSize'in i)?function(b,a){b=b.replace(/\\([^\\]{1})/g,'$1');return a.getElementById&&a.getElementById(b)||W(b,a.getElementsByTagName('*'))}:function(b,a){var d=null;b=b.replace(/\\([^\\]{1})/g,'$1');if(r||a.nodeType!=9){return W(b,a.getElementsByTagName('*'))}if((d=a.getElementById(b))&&d.name==b&&a.getElementsByName){return W(b,a.getElementsByName(b))}return d},bD=function(b,a){a||(a=i);if(z!==a){F(a)}return G(b,a)},bE=function(b,a){a=a.toLowerCase();if(typeof b[a]=='object'){return b.attributes[a]&&b.attributes[a].value||''}return(a=='type'?b.getAttribute(a)||'':bv[a]?b.getAttribute(a,2)||'':bu[a]?b.getAttribute(a)?a:'false':((b=b.getAttributeNode(a))&&b.value)||'')},bF=t.hasAttribute?function(b,a){return b.hasAttribute(a)}:function(b,a){a=a.toLowerCase();if(bl[a]){return!!b[bl[a]]}b=b.getAttributeNode(a);return!!(b&&b.specified)},X=function(b,a,d){var e=typeof b=='string'?b.match(Q):b;typeof a=='string'||(a='');if(e.length==1){a+=bm(e[0],d?T:'f&&f(k);return true;',d)}else{var h=-1,c={},f;while((f=e[++h])){f=f.replace(P,'');if(!c[f]&&(c[f]=true)){a+=bm(f,d?T:'f&&f(k);return true;',d)}}}if(d)return Function('c,s,r,d,h,g,f,v','var N,n,x=0,k=-1,e;main:while((e=c[++k])){'+a+'}return r;');else return Function('e,s,r,d,h,g,f,v','var N,n,x=0,k=e;'+a+'return false;')},H='var z=v[@]||(v[@]=[]),l=z.length-1;while(l>=0&&z[l]!==e)--l;if(l!==-1){break;}z[z.length]=e;',bm=function(b,a,d){var e=0,h,c,f,j,k,o,Y;while(b){e++;if((c=b.match(q.universal))){h=''}else if((c=b.match(q.id))){a='if('+(r?'s.getAttribute(e,"id")':'(e.submit?s.getAttribute(e,"id"):e.id)')+'=="'+c[1]+'"){'+a+'}'}else if((c=b.match(q.tagName))){a='if(e.nodeName'+(r?'=="'+c[1]+'"':bz+'=="'+c[1].toUpperCase()+'"')+'){'+a+'}'}else if((c=b.match(q.className))){a='if((n='+(r?'e.getAttribute("class")':'e.className')+')&&n.length&&(" "+'+(R?'n.toLowerCase()':'n')+'.replace('+bs+'," ")+" ").indexOf(" '+(R?c[1].toLowerCase():c[1])+' ")>-1){'+a+'}'}else if((c=b.match(q.attribute))){if(c[2]&&!w[c[2]]){m('Unsupported operator in attribute selectors "'+b+'"');return''}o='false';if(c[4]){Y=by[c[1].toLowerCase()];c[4]=(Y?c[4].toLowerCase():c[4]).replace(/\\([0-9a-f]{2,2})/g,'\\x$1').replace(/(\x22|\x27)/g,'\\$1')}if(c[2]&&c[4]&&(o=w[c[2]])){o=o.replace(/\%m/g,c[4])}else if(c[2]=='!='||c[2]=='='){o='n'+c[2]+'="'+c[4]+'"'}h='n=s.'+(c[2]?'get':'has')+'Attribute(e,"'+c[1]+'")'+(Y?'.toLowerCase();':';');a=h+'if('+(c[2]?o:'n')+'){'+a+'}'}else if((c=b.match(q.adjacent))){a=(d?'':H.replace(/@/g,e))+a;a='var N'+e+'=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){'+a+'break;}}e=N'+e+';'}else if((c=b.match(q.relative))){a=(d?'':H.replace(/@/g,e))+a;a='var N'+e+'=e;e=e.parentNode.firstChild;while(e&&e!==N'+e+'){if(e.nodeName>"@"){'+a+'}e=e.nextSibling;}e=N'+e+';'}else if((c=b.match(q.children))){a=(d?'':H.replace(/@/g,e))+a;a='var N'+e+'=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){'+a+'break;}e=N'+e+';'}else if((c=b.match(q.ancestor))){a=(d?'':H.replace(/@/g,e))+a;a='var N'+e+'=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){'+a+'}e=N'+e+';'}else{h=false;k=false;for(h in s){if((c=b.match(s[h].Expression))&&c[1]){j=s[h].Callback(c,a);a=j.source;k=j.status;if(k){break}}}if(!k){m('Unknown pseudo-class selector "'+b+'"');return''}if(!h){m('Unknown token in selector "'+b+'"');return''}}if(!c){m('Invalid syntax in selector "'+b+'"');return''}b=c&&c[c.length-1]}return a},Z=function(b,a,d,e){var h;if(!(b&&b.nodeName>'@')){m('Invalid element argument');return false}else if(!a||typeof a!='string'){m('Invalid selector argument');return false}else if(z!==d){F(d||(d=b.ownerDocument))}a=a.replace(P,'');l.SHORTCUTS&&(a=NW.Dom.shortcuts(a,b,d));if(bd!=a){if((h=a.match(O))&&h[0]==a){bc=(h=a.match(Q)).length<2;bd=a;bf=h}else{m('The string "'+a+'", is not a valid CSS selector');return false}}else h=bf;if(!D[a]||U[a]!==d){D[a]=X(bc?[a]:h,'',false);U[a]=d}return D[a](b,ba,[],i,t,d,e,{})},bG=function(b,a){return bb(b,a,function(){return false})[0]||null},bb=function(b,a,d){var e,h,c,f,j,k,o=b;if(arguments.length===0){m('Not enough arguments');return[]}else if(typeof b!='string'){return[]}else if(!(/[>+~*\w\u00a1-\uffff]/.test(b))){m('Invalid or illegal selector string');return[]}else if(a&&!(/1|9|11/).test(a.nodeType)){m('Invalid or illegal context element');return[]}else if(z!==a){F(a||(a=i))}if(l.CACHING&&(f=g.loadResults(o,a,i,t))){return d?bC([],f,d):f}b=b.replace(P,'');l.SHORTCUTS&&(b=NW.Dom.shortcuts(b,a));if((h=be!=b)){if((j=b.match(O))&&j[0]==b){J=(j=b.match(Q)).length<2;be=b;bg=j}else{m('The string "'+b+'", is not a valid CSS selector');return[]}}else j=bg;if(a.nodeType==11){f=a.childNodes}else if(J){if(h){j=b.match(br);k=j[j.length-1];y=k.split(':not')[0];u=b.length-k.length}if(l.UNIQUE_ID&&(j=y.match(C.ID))&&(k=j[1])){if((c=G(k,a))){if(Z(c,b)){d&&d(c);f=[c]}else f=[]}}else if(l.UNIQUE_ID&&(j=b.match(C.ID))&&(k=j[1])){if((c=G(k,i))){if('#'+k==b){d&&d(c);f=[c]}else if(/[>+~]/.test(b)){a=c.parentNode}else{a=c}}else f=[]}if(f){l.CACHING&&g.saveResults(o,a,i,f);return f}if(!r&&bw&&(j=y.match(C.TAG))&&(k=j[1])){if((f=a.getElementsByTagName(k)).length===0)return[];b=b.slice(0,u)+b.slice(u).replace(k,'*')}else if(!r&&bx&&(j=y.match(C.CLASS))&&(k=j[1])){if((f=a.getElementsByClassName(k.replace(/\\([^\\]{1})/g,'$1'))).length===0)return[];b=b.slice(0,u)+b.slice(u).replace('.'+k,bt.test(b.charAt(b.indexOf(k)-1))?'':'*')}}if(!f){if(S){f=/^(?:applet|object)$/i.test(a.nodeName)?a.childNodes:a.all}else{f=a.getElementsByTagName('*')}}if(!E[b]||V[b]!==a){E[b]=X(J?[b]:j,bA,true);V[b]=a}f=E[b](f,ba,[],i,t,a,d,{});l.CACHING&&g.saveResults(o,a,i,f);return f},I=function(b){return b},U={},D={},V={},E={},ba={byId:G,match:Z,select:bb,getAttribute:bE,hasAttribute:bF};Tokens={prefixes:K,encoding:n,operators:bh,whitespace:p,identifier:A,attributes:v,combinators:bi,pseudoclass:B,pseudoparms:bj,quotedvalue:L};g.ACCEPT_NODE=T;g.emit=m;g.byId=bD;g.match=Z;g.first=bG;g.select=bb;g.compile=X;g.configure=bB;g.Config=l;g.Operators=w;g.Selectors=s;g.Snapshot=ba;g.Tokens=Tokens;g.setCache=I;g.shortcuts=I;g.loadResults=I;g.saveResults=I;g.registerOperator=function(b,a){w[b]||(w[b]=a)};g.registerSelector=function(b,a,d){s[b]||(s[b]={Expression:a,Callback:d})};F(i,true)}); | ||
(function(){var h={'a':1,'A':1,'area':1,'AREA':1,'link':1,'LINK':1},g=document.documentElement,f='compareDocumentPosition'in g?function(b,a){return(b.compareDocumentPosition(a)&16)==16}:'contains'in g?function(b,a){return a.nodeType==1&&b.contains(a)}:function(b,a){while((a=a.parentNode)&&a.nodeType==1){if(a===b)return true}return false},i=function(b){return b.getAttribute('href')&&h[b.nodeName]},j=function(b){b=b.firstChild;while(b){if(b.nodeType==3||b.nodeName>'@')return false;b=b.nextSibling}return true},k=function(b,a){var c=1,e=a?'nextSibling':'previousSibling';while((b=b[e])){if(b.nodeName>'@')++c}return c},l=function(b,a){var c=1,e=a?'nextSibling':'previousSibling',d=b.nodeName;while((b=b[e])){if(b.nodeName==d)++c}return c};NW.Dom.Snapshot['contains']=f;NW.Dom.Snapshot['isLink']=i;NW.Dom.Snapshot['isEmpty']=j;NW.Dom.Snapshot['nthOfType']=l;NW.Dom.Snapshot['nthElement']=k})();NW.Dom.registerSelector('nwmatcher:spseudos',/^\:(root|empty|(?:first|last|only)(?:-child|-of-type)|nth(?:-last)?(?:-child|-of-type)\(\s*(even|odd|(?:[-+]{0,1}\d*n\s*)?[-+]{0,1}\s*\d*)\s*\))?(.*)/i,function(b,a){var c,e,d,h=true,g,f;switch(b[1]){case'root':if(b[3])a='if(e===h||s.contains(h,e)){'+a+'}';else a='if(e===h){'+a+'}';break;case'empty':a='if(s.isEmpty(e)){'+a+'}';break;default:if(b[1]&&b[2]){if(b[2]=='n'){a='if(e!==h){'+a+'}';break}else if(b[2]=='even'){c=2;d=0}else if(b[2]=='odd'){c=2;d=1}else{d=((e=b[2].match(/(-?\d+)$/))?parseInt(e[1],10):0);c=((e=b[2].match(/(-?\d*)n/i))?parseInt(e[1],10):0);if(e&&e[1]=='-')c=-1}g=c>1?(/last/i.test(b[1]))?'(n-('+d+'))%'+c+'==0':'n>='+d+'&&(n-('+d+'))%'+c+'==0':c<-1?(/last/i.test(b[1]))?'(n-('+d+'))%'+c+'==0':'n<='+d+'&&(n-('+d+'))%'+c+'==0':c===0?'n=='+d:(/last/i.test(b[1]))?c==-1?'n>='+d:'n<='+d:c==-1?'n<='+d:'n>='+d;a='if(e!==h){n=s['+(/-of-type/i.test(b[1])?'"nthOfType"':'"nthElement"')+'](e,'+(/last/i.test(b[1])?'true':'false')+');if('+g+'){'+a+'}}'}else if(b[1]){c=/first/i.test(b[1])?'previous':'next';e=/only/i.test(b[1])?'previous':'next';d=/first|last/i.test(b[1]);f=/-of-type/i.test(b[1])?'&&n.nodeName!==e.nodeName':'&&n.nodeName<"@"';a='if(e!==h){'+('n=e;while((n=n.'+c+'Sibling)'+f+');if(!n){'+(d?a:'n=e;while((n=n.'+e+'Sibling)'+f+');if(!n){'+a+'}')+'}')+'}'}else{h=false}break}return{'source':a,'status':h}});NW.Dom.registerSelector('nwmatcher:dpseudos',/^\:(link|visited|target|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(([^()]*|.*)\))?(.*)/i,(function(){var h=document,g=NW.Dom.Config,f=NW.Dom.Tokens,i=RegExp('^'+f.whitespace+'|'+f.whitespace+'$','g'),j=RegExp('^((?!:not)('+f.prefixes+'|'+f.identifier+'|\\([^()]*\\))+|\\['+f.attributes+'\\])$');return function(b,a){var c,e=true,d;switch(b[1].match(/^\w+/)[0]){case'not':c=b[3].replace(i,'');if(g.SIMPLENOT&&!j.test(c)){NW.Dom.emit('Negation pseudo-class only accepts simple selectors "'+b.join('')+'"')}else{if('compatMode'in h){a='if(!'+NW.Dom.compile(c,'',false)+'(e,s,r,d,h,g)){'+a+'}'}else{a='if(!s.match(e, "'+c.replace(/\x22/g,'\\"')+'",g)){'+a+'}'}}break;case'checked':a='if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)'+(g.USE_HTML5?'||(/^option$/i.test(e.nodeName)&&(e.selected||e.checked))':'')+'){'+a+'}';break;case'disabled':a='if(((typeof e.form!=="undefined"'+(g.USE_HTML5?'':'&&!(/^hidden$/i).test(e.type)')+')||s.isLink(e))&&e.disabled===true){'+a+'}';break;case'enabled':a='if(((typeof e.form!=="undefined"'+(g.USE_HTML5?'':'&&!(/^hidden$/i).test(e.type)')+')||s.isLink(e))&&e.disabled===false){'+a+'}';break;case'lang':d='';if(b[2])d=b[2].substr(0,2)+'-';a='do{(n=e.lang||"").toLowerCase();if((n==""&&h.lang=="'+b[2].toLowerCase()+'")||(n&&(n=="'+b[2].toLowerCase()+'"||n.substr(0,3)=="'+d.toLowerCase()+'"))){'+a+'break;}}while((e=e.parentNode)&&e!==g);';break;case'target':n=h.location?h.location.hash:'';if(n){a='if(e.id=="'+n.slice(1)+'"){'+a+'}'}break;case'link':a='if(s.isLink(e)&&!e.visited){'+a+'}';break;case'visited':a='if(s.isLink(e)&&e.visited){'+a+'}';break;case'active':a='if(e===d.activeElement){'+a+'}';break;case'hover':a='if(e===d.hoverElement){'+a+'}';break;case'focus':a='hasFocus'in h?'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href||!isNaN(e.tabIndex))){'+a+'}':'if(e===d.activeElement&&(e.type||e.href)){'+a+'}';break;case'selected':a='if(/^option$/i.test(e.nodeName)&&(e.selected||e.checked)){'+a+'}';break;default:e=false;break}return{'source':a,'status':e}}})()); |
@@ -8,5 +8,5 @@ /* | ||
* Author: Diego Perini <diego.perini at gmail com> | ||
* Version: 1.2.5 | ||
* Version: 1.3.0 | ||
* Created: 20070722 | ||
* Release: 20120101 | ||
* Release: 20130110 | ||
* | ||
@@ -19,10 +19,26 @@ * License: | ||
(function(global) { | ||
(function(global, factory) { | ||
var version = 'nwmatcher-1.2.5', | ||
if (typeof module === 'object' && typeof exports === 'object') { | ||
module.exports = function (browserGlobal) { | ||
var exports = { }; | ||
factory(browserGlobal, exports); | ||
return exports; | ||
}; | ||
} else { | ||
if (!global.NW) { | ||
global.NW = { }; | ||
} | ||
if (!global.NW.Dom) { | ||
global.NW.Dom = { }; | ||
} | ||
factory(global, global.NW.Dom); | ||
} | ||
Dom = typeof exports == 'object' ? exports : | ||
((global.NW || (global.NW = { })) && | ||
(global.NW.Dom || (global.NW.Dom = { }))), | ||
})(this, function(global, exports) { | ||
var version = 'nwmatcher-1.3.0', | ||
Dom = exports, | ||
doc = global.document, | ||
@@ -50,3 +66,4 @@ root = doc.documentElement, | ||
combinators = '[\\x20]|[>+~][^>+~]', | ||
pseudoparms = '[-+]?\\d*n?[-+]?\\d*', | ||
pseudoparms = '(?:[-+]?\\d*n)?[-+]?\\d*', | ||
quotedvalue = '"[^"]*"' + "|'[^']*'", | ||
@@ -59,4 +76,5 @@ skipgroup = '\\[.*\\]|\\(.*\\)|\\{.*\\}', | ||
attrcheck = '(' + quotedvalue + '|' + identifier + ')', | ||
attributes = whitespace + '(' + encoding + '+:?' + encoding + '+)' + | ||
attributes = whitespace + '(' + encoding + '*:?' + encoding + '+)' + | ||
whitespace + '(?:' + operators + whitespace + attrcheck + ')?' + whitespace, | ||
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3'), | ||
@@ -82,3 +100,3 @@ | ||
'|\\{' + extensions + '\\}' + | ||
'|,' + | ||
'|(?:,|' + whitespace + ')' + | ||
')+', | ||
@@ -94,3 +112,3 @@ | ||
reSplitGroup = RegExp('(' + | ||
'[^,\\\\\\[\\]]+' + | ||
'[^,\\\\()[\\]]+' + | ||
'|\\[[^[\\]]*\\]|\\[.*\\]' + | ||
@@ -105,3 +123,3 @@ '|\\([^()]+\\)|\\(.*\\)' + | ||
'\\(' + pseudoclass + '\\)|' + | ||
'[^\\x20>+~]|\\\\.)+', 'g'), | ||
'[^\\x20\\t\\n\\r\\f>+~]|\\\\.)+', 'g'), | ||
@@ -112,2 +130,13 @@ reWhiteSpace = /[\x20\t\n\r\f]+/g, | ||
ATTR_BOOLEAN = { | ||
checked: 1, disabled: 1, ismap: 1, | ||
multiple: 1, readonly: 1, selected: 1 | ||
}, | ||
ATTR_DEFAULT = { | ||
value: 'defaultValue', | ||
checked: 'defaultChecked', | ||
selected: 'defaultSelected' | ||
}, | ||
ATTR_URIDATA = { | ||
@@ -160,7 +189,5 @@ action: 2, cite: 2, codebase: 2, data: 2, href: 2, | ||
REFLECTED = { 'value': 1, 'checked': 1, 'selected': 1 }, | ||
TO_UPPER_CASE = IE_LT_9 ? '.toUpperCase()' : '', | ||
ACCEPT_NODE = 'r[r.length]=c[k];if(f&&false===f(c[k]))break;else continue main;', | ||
ACCEPT_NODE = 'r[r.length]=c[k];if(f&&false===f(c[k]))break main;else continue main;', | ||
REJECT_NODE = IE_LT_9 ? 'if(e.nodeName<"A")continue;' : '', | ||
@@ -171,4 +198,4 @@ | ||
SIMPLENOT: true, | ||
USE_HTML5: false, | ||
USE_QSAPI: false, | ||
UNIQUE_ID: true, | ||
USE_HTML5: true, | ||
VERBOSITY: true | ||
@@ -178,5 +205,7 @@ }, | ||
configure = | ||
function(options) { | ||
for (var i in options) { | ||
Config[i] = !!options[i]; | ||
function(option) { | ||
if (typeof option == 'string') { return Config[option]; } | ||
if (typeof option != 'object') { return false; } | ||
for (var i in option) { | ||
Config[i] = !!option[i]; | ||
if (i == 'SIMPLENOT') { | ||
@@ -187,8 +216,7 @@ matchContexts = { }; | ||
selectResolvers = { }; | ||
Config['USE_QSAPI'] = false; | ||
reValidator = RegExp(extendedValidator, 'g'); | ||
} else if (i == 'USE_QSAPI') { | ||
reValidator = RegExp(standardValidator, 'g'); | ||
} | ||
} | ||
reValidator = RegExp(Config.SIMPLENOT ? | ||
standardValidator : extendedValidator, 'g'); | ||
return true; | ||
}, | ||
@@ -207,15 +235,5 @@ | ||
function(message) { | ||
message = 'SYNTAX_ERR: ' + message + ' '; | ||
if (Config.VERBOSITY) { | ||
if (typeof global.DOMException != 'undefined') { | ||
throw { code: 12, message: message }; | ||
} else { | ||
throw new Error(12, message); | ||
} | ||
} else { | ||
if (global.console && global.console.log) { | ||
global.console.log(message); | ||
} else { | ||
global.status += message; | ||
} | ||
if (Config.VERBOSITY) { throw Error(message); } | ||
if (global.console && global.console.log) { | ||
global.console.log(message); | ||
} | ||
@@ -236,3 +254,3 @@ }, | ||
(function() { | ||
var style = document.createElement('div').style; | ||
var style = doc.createElement('div').style; | ||
return style && (style.width = 1) && style.width == '1px'; | ||
@@ -259,3 +277,3 @@ })(); | ||
function(id, from) { | ||
id = id.replace(/\\/g, ''); | ||
id = id.replace(/\\([^\\]{1})/g, '$1'); | ||
return from.getElementById && from.getElementById(id) || | ||
@@ -266,3 +284,3 @@ byIdRaw(id, from.getElementsByTagName('*')); | ||
var element = null; | ||
id = id.replace(/\\/g, ''); | ||
id = id.replace(/\\([^\\]{1})/g, '$1'); | ||
if (XML_DOCUMENT || from.nodeType != 9) { | ||
@@ -280,13 +298,34 @@ return byIdRaw(id, from.getElementsByTagName('*')); | ||
function(id, from) { | ||
switchContext(from || (from = doc)); | ||
from || (from = doc); | ||
if (lastContext !== from) { switchContext(from); } | ||
return _byId(id, from); | ||
}, | ||
getAttr = | ||
getAttribute = | ||
function(node, attribute) { | ||
attribute = attribute.toLowerCase(); | ||
if (typeof node[attribute] == 'object') { | ||
return node.attributes[attribute] && | ||
node.attributes[attribute].value || ''; | ||
} | ||
return ( | ||
attribute == 'type' ? node.getAttribute(attribute) || '' : | ||
ATTR_URIDATA[attribute] ? node.getAttribute(attribute, 2) || '' : | ||
((node = node.attributes[attribute]) && node.value) || ''); | ||
ATTR_BOOLEAN[attribute] ? node.getAttribute(attribute) ? attribute : 'false' : | ||
((node = node.getAttributeNode(attribute)) && node.value) || ''); | ||
}, | ||
hasAttribute = root.hasAttribute ? | ||
function(node, attribute) { | ||
return node.hasAttribute(attribute); | ||
} : | ||
function(node, attribute) { | ||
attribute = attribute.toLowerCase(); | ||
if (ATTR_DEFAULT[attribute]) { | ||
return !!node[ATTR_DEFAULT[attribute]]; | ||
} | ||
node = node.getAttributeNode(attribute); | ||
return !!(node && node.specified); | ||
}, | ||
compile = | ||
@@ -300,3 +339,3 @@ function(selector, source, mode) { | ||
if (parts.length == 1) { | ||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;'); | ||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode); | ||
} else { | ||
@@ -307,3 +346,3 @@ var i = -1, seen = { }, token; | ||
if (!seen[token] && (seen[token] = true)) { | ||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;'); | ||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode); | ||
} | ||
@@ -314,11 +353,17 @@ } | ||
if (mode) | ||
return Function('c,s,r,d,h,g,f', | ||
return Function('c,s,r,d,h,g,f,v', | ||
'var N,n,x=0,k=-1,e;main:while((e=c[++k])){' + source + '}return r;'); | ||
else | ||
return Function('e,s,r,d,h,g,f', | ||
return Function('e,s,r,d,h,g,f,v', | ||
'var N,n,x=0,k=e;' + source + 'return false;'); | ||
}, | ||
FILTER = | ||
'var z=v[@]||(v[@]=[]),l=z.length-1;' + | ||
'while(l>=0&&z[l]!==e)--l;' + | ||
'if(l!==-1){break;}' + | ||
'z[z.length]=e;', | ||
compileSelector = | ||
function(selector, source) { | ||
function(selector, source, mode) { | ||
@@ -337,4 +382,4 @@ var k = 0, expr, match, name, result, status, test, type; | ||
source = 'if(' + (XML_DOCUMENT ? | ||
's.getAttr(e,"id")' : | ||
'(e.submit?s.getAttr(e,"id"):e.id)') + | ||
's.getAttribute(e,"id")' : | ||
'(e.submit?s.getAttribute(e,"id"):e.id)') + | ||
'=="' + match[1] + '"' + | ||
@@ -365,28 +410,21 @@ '){' + source + '}'; | ||
} | ||
name = match[1].toLowerCase(); | ||
if (match[2] && match[4] && (type = Operators[match[2]])) { | ||
test = name in INSENSITIVE_MAP; | ||
match[4] = match[4].replace(/\\([0-9a-f]{2,2})/, '\\x$1'); | ||
type = type.replace(/\%m/g, test ? match[4].toLowerCase() : match[4]); | ||
expr = 'n=s.getAttr(e,"' + name + '")' + (test ? '.toLowerCase()' : '') + ';'; | ||
} else if (!match[2]) { | ||
if (REFLECTED[name]) { | ||
test = 'default' + name.charAt(0).toUpperCase() + name.slice(1); | ||
expr = 'n=e["' + test + '"];'; | ||
type = 'n'; | ||
} else { | ||
expr = 'n=e.attributes["' + name + '"];'; | ||
type = IE_LT_9 ? 'n&&n.specified' : 'n'; | ||
} | ||
test = 'false'; | ||
if (match[4]) { | ||
type = INSENSITIVE_MAP[match[1].toLowerCase()]; | ||
match[4] = | ||
(type ? match[4].toLowerCase() : match[4]) | ||
.replace(/\\([0-9a-f]{2,2})/g, '\\x$1') | ||
.replace(/(\x22|\x27)/g, '\\$1'); | ||
} | ||
if (match[2] && match[4] && (test = Operators[match[2]])) { | ||
test = test.replace(/\%m/g, match[4]); | ||
} else if (match[2] == '!=' || match[2] == '=') { | ||
expr = 'n=e.attributes["' + name + '"];'; | ||
type = 'n&&n.value' + match[2] + '="' + match[4] + '"'; | ||
} else { | ||
expr = ''; | ||
type = 'false'; | ||
test = 'n' + match[2] + '="' + match[4] + '"'; | ||
} | ||
source = expr + 'if(' + type + '){' + source + '}'; | ||
expr = 'n=s.' + (match[2] ? 'get' : 'has') + 'Attribute(e,"' + match[1] + '")' + (type ? '.toLowerCase();' : ';'); | ||
source = expr + 'if(' + (match[2] ? test : 'n') + '){' + source + '}'; | ||
} | ||
else if ((match = selector.match(Patterns.adjacent))) { | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){' + source + 'break;}}e=N' + k + ';'; | ||
@@ -396,10 +434,13 @@ } | ||
else if ((match = selector.match(Patterns.relative))) { | ||
source = 'var N' + k + '=e;e=e.parentNode.firstChild;while(e&&e!=N' + k + '){if(e.nodeName>"@"){' + source + '}e=e.nextSibling;}e=N' + k + ';'; | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;e=e.parentNode.firstChild;while(e&&e!==N' + k + '){if(e.nodeName>"@"){' + source + '}e=e.nextSibling;}e=N' + k + ';'; | ||
} | ||
else if ((match = selector.match(Patterns.children))) { | ||
source = 'var N' + k + '=e;if(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + '}e=N' + k + ';'; | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + 'break;}e=N' + k + ';'; | ||
} | ||
else if ((match = selector.match(Patterns.ancestor))) { | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + '}e=N' + k + ';'; | ||
@@ -409,4 +450,5 @@ } | ||
else { | ||
expr = false; | ||
status = true; | ||
status = false; | ||
for (expr in Selectors) { | ||
@@ -417,5 +459,6 @@ if ((match = selector.match(Selectors[expr].Expression)) && match[1]) { | ||
status = result.status; | ||
if (status) break; | ||
if (status) { break; } | ||
} | ||
} | ||
if (!status) { | ||
@@ -425,2 +468,3 @@ emit('Unknown pseudo-class selector "' + selector + '"'); | ||
} | ||
if (!expr) { | ||
@@ -430,2 +474,3 @@ emit('Unknown token in selector "' + selector + '"'); | ||
} | ||
} | ||
@@ -479,3 +524,3 @@ | ||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback); | ||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, { }); | ||
}, | ||
@@ -494,11 +539,11 @@ | ||
if (arguments.length === 0) { | ||
emit('Missing required selector parameters'); | ||
emit('Not enough arguments'); | ||
return [ ]; | ||
} else if (selector === '') { | ||
emit('Empty selector string'); | ||
return [ ]; | ||
} else if (typeof selector != 'string') { | ||
return [ ]; | ||
} else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) { | ||
emit('Invalid or illegal selector string'); | ||
return [ ]; | ||
} else if (from && !(/1|9|11/).test(from.nodeType)) { | ||
emit('Invalid context element'); | ||
emit('Invalid or illegal context element'); | ||
return [ ]; | ||
@@ -541,3 +586,3 @@ } else if (lastContext !== from) { | ||
if ((parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) { | ||
if (Config.UNIQUE_ID && (parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) { | ||
if ((element = _byId(token, from))) { | ||
@@ -551,3 +596,3 @@ if (match(element, selector)) { | ||
else if ((parts = selector.match(Optimize.ID)) && (token = parts[1])) { | ||
else if (Config.UNIQUE_ID && (parts = selector.match(Optimize.ID)) && (token = parts[1])) { | ||
if ((element = _byId(token, doc))) { | ||
@@ -557,8 +602,5 @@ if ('#' + token == selector) { | ||
elements = [ element ]; | ||
} | ||
if (/[>+~]/.test(selector)) { | ||
} else if (/[>+~]/.test(selector)) { | ||
from = element.parentNode; | ||
} else { | ||
selector = selector.replace('#' + token, '*'); | ||
lastPosition -= token.length + 1; | ||
from = element; | ||
@@ -580,3 +622,3 @@ } | ||
else if (!XML_DOCUMENT && GEBCN && (parts = lastSlice.match(Optimize.CLASS)) && (token = parts[1])) { | ||
if ((elements = from.getElementsByClassName(token.replace(/\\/g, ''))).length === 0) return [ ]; | ||
if ((elements = from.getElementsByClassName(token.replace(/\\([^\\]{1})/g, '$1'))).length === 0) return [ ]; | ||
selector = selector.slice(0, lastPosition) + selector.slice(lastPosition).replace('.' + token, | ||
@@ -602,3 +644,3 @@ reOptimizeSelector.test(selector.charAt(selector.indexOf(token) - 1)) ? '' : '*'); | ||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback); | ||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, { }); | ||
@@ -610,2 +652,4 @@ Config.CACHING && Dom.saveResults(original, from, doc, elements); | ||
FN = function(x) { return x; }, | ||
matchContexts = { }, | ||
@@ -621,3 +665,4 @@ matchResolvers = { }, | ||
select: select, | ||
getAttr: getAttr | ||
getAttribute: getAttribute, | ||
hasAttribute: hasAttribute | ||
}; | ||
@@ -650,13 +695,14 @@ | ||
Dom.Config = Config; | ||
Dom.Operators = Operators; | ||
Dom.Selectors = Selectors; | ||
Dom.Snapshot = Snapshot; | ||
Dom.Tokens = Tokens; | ||
Dom.setCache = function() { return; }; | ||
Dom.loadResults = function() { return; }; | ||
Dom.saveResults = function() { return; }; | ||
Dom.setCache = FN; | ||
Dom.shortcuts = FN; | ||
Dom.loadResults = FN; | ||
Dom.saveResults = FN; | ||
Dom.shortcuts = function(x) { return x; }; | ||
Dom.registerOperator = | ||
@@ -677,2 +723,2 @@ function(symbol, resolver) { | ||
})(this); | ||
}); |
@@ -8,5 +8,5 @@ /* | ||
* Author: Diego Perini <diego.perini at gmail com> | ||
* Version: 1.2.5 | ||
* Version: 1.3.0 | ||
* Created: 20070722 | ||
* Release: 20120101 | ||
* Release: 20130110 | ||
* | ||
@@ -19,15 +19,30 @@ * License: | ||
(function(global) { | ||
(function(global, factory) { | ||
var version = 'nwmatcher-1.2.5', | ||
if (typeof module === 'object' && typeof exports === 'object') { | ||
// in a Node.js environment, the nwmatcher functions will operate on | ||
// the passed "browserGlobal" and will be returned in an object | ||
module.exports = function (browserGlobal) { | ||
var exports = { }; | ||
factory(browserGlobal, exports); | ||
return exports; | ||
}; | ||
} else { | ||
// in a browser environment, the nwmatcher functions will operate on | ||
// the "global" loading them and be attached to "global.NW.Dom" | ||
if (!global.NW) { | ||
global.NW = { }; | ||
} | ||
if (!global.NW.Dom) { | ||
global.NW.Dom = { }; | ||
} | ||
factory(global, global.NW.Dom); | ||
} | ||
// export the public API for CommonJS implementations, | ||
// for headless JS engines or for standard web browsers | ||
Dom = | ||
// as CommonJS/NodeJS module | ||
typeof exports == 'object' ? exports : | ||
// create or extend NW namespace | ||
((global.NW || (global.NW = { })) && | ||
(global.NW.Dom || (global.NW.Dom = { }))), | ||
})(this, function(global, exports) { | ||
var version = 'nwmatcher-1.3.0', | ||
Dom = exports, | ||
// processing context & root element | ||
@@ -69,3 +84,3 @@ doc = global.document, | ||
// an+b format params for pseudo-classes | ||
pseudoparms = '[-+]?\\d*n?[-+]?\\d*', | ||
pseudoparms = '(?:[-+]?\\d*n)?[-+]?\\d*', | ||
@@ -75,10 +90,10 @@ // CSS quoted string values | ||
// skip group of round brackets | ||
// skip round brackets groups | ||
skipround = '\\([^()]+\\)|\\(.*\\)', | ||
// skip group of curly brackets | ||
// skip curly brackets groups | ||
skipcurly = '\\{[^{}]+\\}|\\{.*\\}', | ||
// skip group of square brackets | ||
// skip square brackets groups | ||
skipsquare = '\\[[^[\\]]*\\]|\\[.*\\]', | ||
// skip [ ], ( ), { } groups in token tails | ||
// skip [ ], ( ), { } brackets groups | ||
skipgroup = '\\[.*\\]|\\(.*\\)|\\{.*\\}', | ||
@@ -98,3 +113,3 @@ | ||
attrcheck = '(' + quotedvalue + '|' + identifier + ')', | ||
attributes = whitespace + '(' + encoding + '+:?' + encoding + '+)' + | ||
attributes = whitespace + '(' + encoding + '*:?' + encoding + '+)' + | ||
whitespace + '(?:' + operators + whitespace + attrcheck + ')?' + whitespace, | ||
@@ -140,3 +155,3 @@ attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3'), | ||
// selector group separator (comma) | ||
'|,' + | ||
'|(?:,|' + whitespace + ')' + | ||
// close match group | ||
@@ -168,3 +183,3 @@ ')+', | ||
reSplitGroup = new RegExp('(' + | ||
'[^,\\\\\\[\\]]+' + | ||
'[^,\\\\()[\\]]+' + | ||
'|' + skipsquare + | ||
@@ -180,3 +195,3 @@ '|' + skipround + | ||
'\\(' + pseudoclass + '\\)|' + | ||
'[^\\x20>+~]|\\\\.)+', 'g'), | ||
'[^\\x20\\t\\r\\n\\f>+~]|\\\\.)+', 'g'), | ||
@@ -343,8 +358,9 @@ // for in excess whitespace removal | ||
// :enabled :disabled bugs with hidden fields (Firefox 3.5 QSA bug) | ||
// http://www.w3.org/TR/html5/interactive-elements.html#selector-enabled | ||
// IE8 QSA has problems too and throws error with these dynamic pseudos | ||
// :enabled :disabled bugs with hidden fields (Firefox 3.5) | ||
// http://www.w3.org/TR/html5/links.html#selector-enabled | ||
// http://www.w3.org/TR/css3-selectors/#enableddisabled | ||
// not supported by IE8 Query Selector | ||
element = doc.createElement('input'); | ||
element.setAttribute('type', 'hidden'); | ||
expect(':enabled', div, element, 1) && | ||
expect(':enabled', div, element, 0) && | ||
pattern.push(':enabled', ':disabled'); | ||
@@ -395,8 +411,8 @@ | ||
ATTR_DEFAULT = { | ||
value: 'defaultValue', | ||
checked: 'defaultChecked', | ||
selected: 'defaultSelected' | ||
'value': 'defaultValue', | ||
'checked': 'defaultChecked', | ||
'selected': 'defaultSelected' | ||
}, | ||
// attribute referencing URI data values need special treatment in IE | ||
// attributes referencing URI data values need special treatment in IE | ||
ATTR_URIDATA = { | ||
@@ -471,5 +487,5 @@ 'action': 2, 'cite': 2, 'codebase': 2, 'data': 2, 'href': 2, | ||
// structural pseudo-classes and child selectors | ||
spseudos: /^\:((root|empty|nth-)?(?:(first|last|only)-)?(child)?-?(of-type)?)(?:\(([^\x29]*)\))?(.*)/, | ||
spseudos: /^\:(root|empty|(?:first|last|only)(?:-child|-of-type)|nth(?:-last)?(?:-child|-of-type)\(\s*(even|odd|(?:[-+]{0,1}\d*n\s*)?[-+]{0,1}\s*\d*)\s*\))?(.*)/i, | ||
// uistates + dynamic + negation pseudo-classes | ||
dpseudos: /^\:(link|visited|target|lang|not|active|focus|hover|checked|disabled|enabled|selected)(?:\((["']*)(.*?(\(.*\))?[^'"()]*?)\2\))?(.*)/, | ||
dpseudos: /^\:(link|visited|target|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(([^()]*|.*)\))?(.*)/i, | ||
// element attribute matcher | ||
@@ -590,3 +606,3 @@ attribute: new RegExp('^\\[' + attrmatcher + '\\](.*)'), | ||
function(id, from) { | ||
id = id.replace(/\\/g, ''); | ||
id = id.replace(/\\([^\\]{1})/g, '$1'); | ||
return from.getElementById && from.getElementById(id) || | ||
@@ -597,3 +613,3 @@ byIdRaw(id, from.getElementsByTagName('*')); | ||
var element = null; | ||
id = id.replace(/\\/g, ''); | ||
id = id.replace(/\\([^\\]{1})/g, '$1'); | ||
if (XML_DOCUMENT || from.nodeType != 9) { | ||
@@ -613,3 +629,4 @@ return byIdRaw(id, from.getElementsByTagName('*')); | ||
function(id, from) { | ||
switchContext(from || (from = doc)); | ||
from || (from = doc); | ||
if (lastContext !== from) { switchContext(from); } | ||
return _byId(id, from); | ||
@@ -663,3 +680,4 @@ }, | ||
function(tag, from) { | ||
switchContext(from || (from = doc)); | ||
from || (from = doc); | ||
if (lastContext !== from) { switchContext(from); } | ||
return _byTag(tag, from); | ||
@@ -672,3 +690,3 @@ }, | ||
function(name, from) { | ||
return select('[name="' + name.replace(/\\/g, '') + '"]', from); | ||
return select('[name="' + name.replace(/\\([^\\]{1})/g, '$1') + '"]', from); | ||
}, | ||
@@ -681,3 +699,3 @@ | ||
var i = -1, j = i, data = [ ], element, elements = _byTag('*', from), n; | ||
name = ' ' + (QUIRKS_MODE ? name.toLowerCase() : name).replace(/\\/g, '') + ' '; | ||
name = ' ' + (QUIRKS_MODE ? name.toLowerCase() : name).replace(/\\([^\\]{1})/g, '$1') + ' '; | ||
while ((element = elements[++i])) { | ||
@@ -698,3 +716,3 @@ n = XML_DOCUMENT ? element.getAttribute('class') : element.className; | ||
return (BUGGY_GEBCN || BUGGY_QUIRKS_GEBCN || XML_DOCUMENT || !from.getElementsByClassName) ? | ||
byClassRaw(name, from) : slice.call(from.getElementsByClassName(name.replace(/\\/g, '')), 0); | ||
byClassRaw(name, from) : slice.call(from.getElementsByClassName(name.replace(/\\([^\\]{1})/g, '$1')), 0); | ||
}, | ||
@@ -706,3 +724,4 @@ | ||
function(name, from) { | ||
switchContext(from || (from = doc)); | ||
from || (from = doc); | ||
if (lastContext !== from) { switchContext(from); } | ||
return _byClass(name, from); | ||
@@ -735,10 +754,13 @@ }, | ||
attribute = attribute.toLowerCase(); | ||
if (ATTR_DEFAULT[attribute]) { | ||
return node[ATTR_DEFAULT[attribute]] || ''; | ||
if (typeof node[attribute] == 'object') { | ||
return node.attributes[attribute] && | ||
node.attributes[attribute].value || ''; | ||
} | ||
return ( | ||
// 'type' can only be read by using native getAttribute | ||
attribute == 'type' ? node.getAttribute(attribute) || '' : | ||
// specific URI data attributes (parameter 2 to fix IE bug) | ||
ATTR_URIDATA[attribute] ? node.getAttribute(attribute, 2) || '' : | ||
// boolean attributes should return name instead of true/false | ||
ATTR_BOOLEAN[attribute] ? node.getAttribute(attribute) ? attribute : '' : | ||
ATTR_BOOLEAN[attribute] ? node.getAttribute(attribute) ? attribute : 'false' : | ||
((node = node.getAttributeNode(attribute)) && node.value) || ''); | ||
@@ -760,6 +782,5 @@ }, | ||
} | ||
// need to get at AttributeNode first on IE | ||
// read the attribute node | ||
node = node.getAttributeNode(attribute); | ||
// use both "specified" & "nodeValue" properties | ||
return !!(node && (node.specified || node.nodeValue)); | ||
return !!(node && node.specified); | ||
}, | ||
@@ -810,7 +831,9 @@ | ||
// set working mode | ||
// get/set (string/object) working modes | ||
configure = | ||
function(options) { | ||
for (var i in options) { | ||
Config[i] = !!options[i]; | ||
function(option) { | ||
if (typeof option == 'string') { return Config[option]; } | ||
if (typeof option != 'object') { return false; } | ||
for (var i in option) { | ||
Config[i] = !!option[i]; | ||
if (i == 'SIMPLENOT') { | ||
@@ -822,8 +845,9 @@ matchContexts = { }; | ||
Config['USE_QSAPI'] = false; | ||
reValidator = new RegExp(extendedValidator, 'g'); | ||
} else if (i == 'USE_QSAPI') { | ||
Config[i] = !!options[i] && NATIVE_QSAPI; | ||
reValidator = new RegExp(standardValidator, 'g'); | ||
Config[i] = !!option[i] && NATIVE_QSAPI; | ||
} | ||
} | ||
reValidator = new RegExp(Config.SIMPLENOT ? | ||
standardValidator : extendedValidator, 'g'); | ||
return true; | ||
}, | ||
@@ -834,16 +858,5 @@ | ||
function(message) { | ||
message = 'SYNTAX_ERR: ' + message + ' '; | ||
if (Config.VERBOSITY) { | ||
// FF/Safari/Opera DOMException.SYNTAX_ERR = 12 | ||
if (typeof global.DOMException != 'undefined') { | ||
throw { code: 12, message: message }; | ||
} else { | ||
throw new Error(12, message); | ||
} | ||
} else { | ||
if (global.console && global.console.log) { | ||
global.console.log(message); | ||
} else { | ||
global.status += message; | ||
} | ||
if (Config.VERBOSITY) { throw new Error(message); } | ||
if (global.console && global.console.log) { | ||
global.console.log(message); | ||
} | ||
@@ -866,4 +879,8 @@ }, | ||
// strict QSA match all non-unique IDs (false) | ||
// speed & libs compat match unique ID (true) | ||
UNIQUE_ID: true, | ||
// HTML5 handling for the ":checked" pseudo-class | ||
USE_HTML5: false, | ||
USE_HTML5: true, | ||
@@ -881,3 +898,3 @@ // controls enabling the Query Selector API branch | ||
// code string reused to build compiled functions | ||
ACCEPT_NODE = 'r[r.length]=c[k];if(f&&false===f(c[k]))break;else continue main;', | ||
ACCEPT_NODE = 'r[r.length]=c[k];if(f&&false===f(c[k]))break main;else continue main;', | ||
@@ -896,3 +913,3 @@ // compile a comma separated group of selector | ||
if (parts.length == 1) { | ||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;'); | ||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode); | ||
} else { | ||
@@ -906,3 +923,3 @@ // for each selector in the group | ||
if (!seen[token] && (seen[token] = true)) { | ||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;'); | ||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode); | ||
} | ||
@@ -914,7 +931,7 @@ } | ||
// for select method | ||
return new Function('c,s,r,d,h,g,f', | ||
return new Function('c,s,r,d,h,g,f,v', | ||
'var N,n,x=0,k=-1,e;main:while((e=c[++k])){' + source + '}return r;'); | ||
} else { | ||
// for match method | ||
return new Function('e,s,r,d,h,g,f', | ||
return new Function('e,s,r,d,h,g,f,v', | ||
'var N,n,x=0,k=e;' + source + 'return false;'); | ||
@@ -924,6 +941,13 @@ } | ||
// allows to cache already visited nodes | ||
FILTER = | ||
'var z=v[@]||(v[@]=[]),l=z.length-1;' + | ||
'while(l>=0&&z[l]!==e)--l;' + | ||
'if(l!==-1){break;}' + | ||
'z[z.length]=e;', | ||
// compile a CSS3 string selector into ad-hoc javascript matching function | ||
// @return string (to be compiled) | ||
compileSelector = | ||
function(selector, source) { | ||
function(selector, source, mode) { | ||
@@ -1003,6 +1027,8 @@ var a, b, n, k = 0, expr, match, result, status, test, type; | ||
// replace escaped values and HTML entities | ||
match[4] = match[4].replace(/\\([0-9a-f]{2,2})/, '\\x$1'); | ||
match[4] = match[4].replace(/(\x22|\x27)/g, '\\$1'); | ||
match[4] = match[4].replace(/\\([0-9a-f]{2,2})/g, '\\x$1'); | ||
test = (XML_DOCUMENT ? XHTML_TABLE : HTML_TABLE)[expr.toLowerCase()]; | ||
type = type.replace(/\%m/g, test ? match[4].toLowerCase() : match[4]); | ||
} else if (match[2] == '!=' || match[2] == '=') { | ||
match[4] = match[4].replace(/(\x22|\x27)/g, '\\$1'); | ||
type = 'n' + match[2] + '="' + match[4] + '"'; | ||
@@ -1022,4 +1048,5 @@ } | ||
else if ((match = selector.match(Patterns.adjacent))) { | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = NATIVE_TRAVERSAL_API ? | ||
'var N' + k + '=e;if(e&&(e=e.previousElementSibling)){' + source + '}e=N' + k + ';' : | ||
'var N' + k + '=e;while(e&&(e=e.previousElementSibling)){' + source + 'break;}e=N' + k + ';' : | ||
'var N' + k + '=e;while(e&&(e=e.previousSibling)){if(e.nodeName>"@"){' + source + 'break;}}e=N' + k + ';'; | ||
@@ -1031,2 +1058,3 @@ } | ||
else if ((match = selector.match(Patterns.relative))) { | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = NATIVE_TRAVERSAL_API ? | ||
@@ -1042,3 +1070,4 @@ ('var N' + k + '=e;e=e.parentNode.firstElementChild;' + | ||
else if ((match = selector.match(Patterns.children))) { | ||
source = 'var N' + k + '=e;if(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + '}e=N' + k + ';'; | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + 'break;}e=N' + k + ';'; | ||
} | ||
@@ -1049,2 +1078,3 @@ | ||
else if ((match = selector.match(Patterns.ancestor))) { | ||
source = (mode ? '' : FILTER.replace(/@/g, k)) + source; | ||
source = 'var N' + k + '=e;while(e&&e!==h&&e!==g&&(e=e.parentNode)){' + source + '}e=N' + k + ';'; | ||
@@ -1060,7 +1090,6 @@ } | ||
switch (match[2]) { | ||
switch (match[1]) { | ||
case 'root': | ||
// element root of the document | ||
if (match[7]) { | ||
if (match[3]) { | ||
source = 'if(e===h||s.contains(h,e)){' + source + '}'; | ||
@@ -1078,10 +1107,10 @@ } else { | ||
default: | ||
if (match[2] && match[6]) { | ||
if (match[6] == 'n') { | ||
if (match[1] && match[2]) { | ||
if (match[2] == 'n') { | ||
source = 'if(e!==h){' + source + '}'; | ||
break; | ||
} else if (match[6] == 'even') { | ||
} else if (match[2] == 'even') { | ||
a = 2; | ||
b = 0; | ||
} else if (match[6] == 'odd') { | ||
} else if (match[2] == 'odd') { | ||
a = 2; | ||
@@ -1091,4 +1120,4 @@ b = 1; | ||
// assumes correct "an+b" format, "b" before "a" to keep "n" values | ||
b = ((n = match[6].match(/(-?\d+)$/)) ? parseInt(n[1], 10) : 0); | ||
a = ((n = match[6].match(/(-?\d*)n/)) ? parseInt(n[1], 10) : 0); | ||
b = ((n = match[2].match(/(-?\d+)$/)) ? parseInt(n[1], 10) : 0); | ||
a = ((n = match[2].match(/(-?\d*)n/i)) ? parseInt(n[1], 10) : 0); | ||
if (n && n[1] == '-') a = -1; | ||
@@ -1099,9 +1128,9 @@ } | ||
// see here: http://www.w3.org/TR/css3-selectors/#nth-child-pseudo | ||
test = b < 1 && a > 1 ? '(n-(' + b + '))%' + a + '==0' : a > +1 ? | ||
(match[3] == 'last') ? '(n-(' + b + '))%' + a + '==0' : | ||
test = a > 1 ? | ||
(/last/i.test(match[1])) ? '(n-(' + b + '))%' + a + '==0' : | ||
'n>=' + b + '&&(n-(' + b + '))%' + a + '==0' : a < -1 ? | ||
(match[3] == 'last') ? '(n-(' + b + '))%' + a + '==0' : | ||
(/last/i.test(match[1])) ? '(n-(' + b + '))%' + a + '==0' : | ||
'n<=' + b + '&&(n-(' + b + '))%' + a + '==0' : a=== 0 ? | ||
'n==' + b : | ||
(match[3] == 'last') ? | ||
(/last/i.test(match[1])) ? | ||
a == -1 ? 'n>=' + b : 'n<=' + b : | ||
@@ -1113,4 +1142,4 @@ a == -1 ? 'n<=' + b : 'n>=' + b; | ||
'if(e!==h){' + | ||
'n=s[' + (match[5] ? '"nthOfType"' : '"nthElement"') + ']' + | ||
'(e,' + (match[3] == 'last' ? 'true' : 'false') + ');' + | ||
'n=s[' + (/-of-type/i.test(match[1]) ? '"nthOfType"' : '"nthElement"') + ']' + | ||
'(e,' + (/last/i.test(match[1]) ? 'true' : 'false') + ');' + | ||
'if(' + test + '){' + source + '}' + | ||
@@ -1121,7 +1150,7 @@ '}'; | ||
// 6 cases: 3 (first, last, only) x 1 (child) x 2 (-of-type) | ||
a = match[3] == 'first' ? 'previous' : 'next'; | ||
n = match[3] == 'only' ? 'previous' : 'next'; | ||
b = match[3] == 'first' || match[3] == 'last'; | ||
a = /first/i.test(match[1]) ? 'previous' : 'next'; | ||
n = /only/i.test(match[1]) ? 'previous' : 'next'; | ||
b = /first|last/i.test(match[1]); | ||
type = match[5] ? '&&n.nodeName!=e.nodeName' : '&&n.nodeName<"@"'; | ||
type = /-of-type/i.test(match[1]) ? '&&n.nodeName!=e.nodeName' : '&&n.nodeName<"@"'; | ||
@@ -1144,3 +1173,3 @@ source = 'if(e!==h){' + | ||
switch (match[1]) { | ||
switch (match[1].match(/^\w+/)[0]) { | ||
// CSS3 negation pseudo-class | ||
@@ -1159,3 +1188,3 @@ case 'not': | ||
if ('compatMode' in doc) { | ||
source = 'if(!' + compile([expr], '', false) + '(e,s,r,d,h,g)){' + source + '}'; | ||
source = 'if(!' + compile(expr, '', false) + '(e,s,r,d,h,g)){' + source + '}'; | ||
} else { | ||
@@ -1170,12 +1199,17 @@ source = 'if(!s.match(e, "' + expr.replace(/\x22/g, '\\"') + '",g)){' + source +'}'; | ||
// for radio buttons checkboxes (HTML4) and options (HTML5) | ||
test = 'if((typeof e.form!="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)'; | ||
source = (Config.USE_HTML5 ? test + '||(/^option$/i.test(e.nodeName)&&e.selected)' : test) + '){' + source + '}'; | ||
source = 'if((typeof e.form!=="undefined"&&(/^(?:radio|checkbox)$/i).test(e.type)&&e.checked)' + | ||
(Config.USE_HTML5 ? '||(/^option$/i.test(e.nodeName)&&(e.selected||e.checked))' : '') + | ||
'){' + source + '}'; | ||
break; | ||
case 'disabled': | ||
// does not consider hidden input fields | ||
source = 'if(((typeof e.form!="undefined"&&!(/^hidden$/i).test(e.type))||s.isLink(e))&&e.disabled){' + source + '}'; | ||
source = 'if(((typeof e.form!=="undefined"' + | ||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') + | ||
')||s.isLink(e))&&e.disabled===true){' + source + '}'; | ||
break; | ||
case 'enabled': | ||
// does not consider hidden input fields | ||
source = 'if(((typeof e.form!="undefined"&&!(/^hidden$/i).test(e.type))||s.isLink(e))&&!e.disabled){' + source + '}'; | ||
source = 'if(((typeof e.form!=="undefined"' + | ||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') + | ||
')||s.isLink(e))&&e.disabled===false){' + source + '}'; | ||
break; | ||
@@ -1186,6 +1220,6 @@ | ||
test = ''; | ||
if (match[3]) test = match[3].substr(0, 2) + '-'; | ||
if (match[2]) test = match[2].substr(0, 2) + '-'; | ||
source = 'do{(n=e.lang||"").toLowerCase();' + | ||
'if((n==""&&h.lang=="' + match[3].toLowerCase() + '")||' + | ||
'(n&&(n=="' + match[3].toLowerCase() + | ||
'if((n==""&&h.lang=="' + match[2].toLowerCase() + '")||' + | ||
'(n&&(n=="' + match[2].toLowerCase() + | ||
'"||n.substr(0,3)=="' + test.toLowerCase() + '")))' + | ||
@@ -1224,3 +1258,3 @@ '{' + source + 'break;}}while((e=e.parentNode)&&e!==g);'; | ||
source = NATIVE_FOCUS ? | ||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href)){' + source + '}' : | ||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href||!isNaN(e.tabIndex))){' + source + '}' : | ||
'if(e===d.activeElement&&(e.type||e.href)){' + source + '}'; | ||
@@ -1234,3 +1268,3 @@ break; | ||
expr = BUGGY_SELECTED ? '||(n=e.parentNode)&&n.options[n.selectedIndex]===e' : ''; | ||
source = 'if(/^option$/i.test(e.nodeName)&&(e.selected' + expr + ')){' + source + '}'; | ||
source = 'if(/^option$/i.test(e.nodeName)&&(e.selected||e.checked' + expr + ')){' + source + '}'; | ||
break; | ||
@@ -1249,4 +1283,3 @@ | ||
expr = false; | ||
status = true; | ||
status = false; | ||
for (expr in Selectors) { | ||
@@ -1257,3 +1290,3 @@ if ((match = selector.match(Selectors[expr].Expression)) && match[1]) { | ||
status = result.status; | ||
if (status) break; | ||
if (status) { break; } | ||
} | ||
@@ -1339,3 +1372,3 @@ } | ||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback); | ||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, { }); | ||
}, | ||
@@ -1360,11 +1393,11 @@ | ||
if (arguments.length === 0) { | ||
emit('Missing required selector parameters'); | ||
emit('Not enough arguments'); | ||
return [ ]; | ||
} else if (selector === '') { | ||
emit('Empty selector string'); | ||
return [ ]; | ||
} else if (typeof selector != 'string') { | ||
return [ ]; | ||
} else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) { | ||
emit('Invalid or illegal selector string'); | ||
return [ ]; | ||
} else if (from && !(/1|9|11/).test(from.nodeType)) { | ||
emit('Invalid context element'); | ||
emit('Invalid or illegal context element'); | ||
return [ ]; | ||
@@ -1384,3 +1417,3 @@ } else if (lastContext !== from) { | ||
case '#': | ||
if ((element = _byId(selector.slice(1), from))) { | ||
if (Config.UNIQUE_ID && (element = _byId(selector.slice(1), from))) { | ||
elements = [ element ]; | ||
@@ -1450,3 +1483,3 @@ } else elements = [ ]; | ||
// ID optimization RTL, to reduce number of elements to visit | ||
if ((parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) { | ||
if (Config.UNIQUE_ID && (parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) { | ||
if ((element = _byId(token, from))) { | ||
@@ -1461,3 +1494,3 @@ if (match(element, selector)) { | ||
// ID optimization LTR, to reduce selection context searches | ||
else if ((parts = selector.match(Optimize.ID)) && (token = parts[1])) { | ||
else if (Config.UNIQUE_ID && (parts = selector.match(Optimize.ID)) && (token = parts[1])) { | ||
if ((element = _byId(token, doc))) { | ||
@@ -1467,8 +1500,5 @@ if ('#' + token == selector) { | ||
elements = [ element ]; | ||
} | ||
if (/[>+~]/.test(selector)) { | ||
} else if (/[>+~]/.test(selector)) { | ||
from = element.parentNode; | ||
} else { | ||
selector = selector.replace('#' + token, '*'); | ||
lastPosition -= token.length + 1; | ||
from = element; | ||
@@ -1529,3 +1559,3 @@ } | ||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback); | ||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, { }); | ||
@@ -1539,2 +1569,5 @@ Config.CACHING && Dom.saveResults(original, from, doc, elements); | ||
// empty function handler | ||
FN = function(x) { return x; }, | ||
// compiled match functions returning booleans | ||
@@ -1573,3 +1606,3 @@ matchContexts = { }, | ||
match: match | ||
}; | ||
}, | ||
@@ -1636,12 +1669,12 @@ Tokens = { | ||
// initialize caching for each document | ||
Dom.setCache = function() { return; }; | ||
Dom.setCache = FN; | ||
// load previously collected result set | ||
Dom.loadResults = function() { return; }; | ||
Dom.loadResults = FN; | ||
// save previously collected result set | ||
Dom.saveResults = function() { return; }; | ||
Dom.saveResults = FN; | ||
// handle missing context in selector strings | ||
Dom.shortcuts = function(x) { return x; }; | ||
Dom.shortcuts = FN; | ||
@@ -1685,2 +1718,2 @@ // options enabing specific engine functionality | ||
})(this); | ||
}); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7033326
26
29001
2