mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 10:52:47 +00:00
updated bunch of file paths and changed the way posts are loaded
This commit is contained in:
184
node_modules/nwmatcher/src/modules/nwmatcher-cache.js
generated
vendored
Normal file
184
node_modules/nwmatcher/src/modules/nwmatcher-cache.js
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* Caching/memoization module for NWMatcher
|
||||
*
|
||||
* Added capabilities:
|
||||
*
|
||||
* - Mutation Events are feature tested and used safely
|
||||
* - handle caching different document types HTML/XML/SVG
|
||||
* - store result sets for different selectors / contexts
|
||||
* - simultaneously control mutation on multiple documents
|
||||
*
|
||||
*/
|
||||
|
||||
(function(global) {
|
||||
|
||||
// export the public API for CommonJS implementations,
|
||||
// for headless JS engines or for standard web browsers
|
||||
var Dom =
|
||||
// as CommonJS/NodeJS module
|
||||
typeof exports == 'object' ? exports :
|
||||
// create or extend NW namespace
|
||||
((global.NW || (global.NW = global.Object())) &&
|
||||
(global.NW.Dom || (global.NW.Dom = global.Object()))),
|
||||
|
||||
Contexts = global.Object(),
|
||||
Results = global.Object(),
|
||||
|
||||
isEnabled = false,
|
||||
isExpired = true,
|
||||
isPaused = false,
|
||||
|
||||
context = global.document,
|
||||
root = context.documentElement,
|
||||
|
||||
// last time cache initialization was called
|
||||
lastCalled = 0,
|
||||
|
||||
// minimum time allowed between calls to the cache initialization
|
||||
minCacheRest = 15, //ms
|
||||
|
||||
mutationTest =
|
||||
function(type, callback) {
|
||||
var isSupported = false,
|
||||
root = document.documentElement,
|
||||
div = document.createElement('div'),
|
||||
handler = function() { isSupported = true; };
|
||||
root.insertBefore(div, root.firstChild);
|
||||
div.addEventListener(type, handler, true);
|
||||
if (callback && callback.call) callback(div);
|
||||
div.removeEventListener(type, handler, true);
|
||||
root.removeChild(div);
|
||||
return isSupported;
|
||||
},
|
||||
|
||||
// check for Mutation Events, DOMAttrModified should be
|
||||
// enough to ensure DOMNodeInserted/DOMNodeRemoved exist
|
||||
HACKED_MUTATION_EVENTS = false,
|
||||
|
||||
NATIVE_MUTATION_EVENTS = root.addEventListener ?
|
||||
mutationTest('DOMAttrModified', function(e) { e.setAttribute('id', 'nw'); }) : false,
|
||||
|
||||
loadResults =
|
||||
function(selector, from, doc, root) {
|
||||
if (isEnabled && !isPaused) {
|
||||
if (!isExpired) {
|
||||
if (Results[selector] && Contexts[selector] === from) {
|
||||
return Results[selector];
|
||||
}
|
||||
} else {
|
||||
// pause caching while we are getting
|
||||
// hammered by dom mutations (jdalton)
|
||||
now = (new global.Date).getTime();
|
||||
if ((now - lastCalled) < minCacheRest) {
|
||||
isPaused = isExpired = true;
|
||||
global.setTimeout(function() { isPaused = false; }, minCacheRest);
|
||||
} else setCache(true, doc);
|
||||
lastCalled = now;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
saveResults =
|
||||
function(selector, from, doc, data) {
|
||||
Contexts[selector] = from;
|
||||
Results[selector] = data;
|
||||
return;
|
||||
},
|
||||
|
||||
/*-------------------------------- CACHING ---------------------------------*/
|
||||
|
||||
// invoked by mutation events to expire cached parts
|
||||
mutationWrapper =
|
||||
function(event) {
|
||||
var d = event.target.ownerDocument || event.target;
|
||||
stopMutation(d);
|
||||
expireCache(d);
|
||||
},
|
||||
|
||||
// append mutation events
|
||||
startMutation =
|
||||
function(d) {
|
||||
if (!d.isCaching && d.addEventListener) {
|
||||
// FireFox/Opera/Safari/KHTML have support for Mutation Events
|
||||
d.addEventListener('DOMAttrModified', mutationWrapper, true);
|
||||
d.addEventListener('DOMNodeInserted', mutationWrapper, true);
|
||||
d.addEventListener('DOMNodeRemoved', mutationWrapper, true);
|
||||
d.isCaching = true;
|
||||
}
|
||||
},
|
||||
|
||||
// remove mutation events
|
||||
stopMutation =
|
||||
function(d) {
|
||||
if (d.isCaching && d.removeEventListener) {
|
||||
d.removeEventListener('DOMAttrModified', mutationWrapper, true);
|
||||
d.removeEventListener('DOMNodeInserted', mutationWrapper, true);
|
||||
d.removeEventListener('DOMNodeRemoved', mutationWrapper, true);
|
||||
d.isCaching = false;
|
||||
}
|
||||
},
|
||||
|
||||
// enable/disable context caching system
|
||||
// @d optional document context (iframe, xml document)
|
||||
// script loading context will be used as default context
|
||||
setCache =
|
||||
function(enable, d) {
|
||||
if (!!enable) {
|
||||
isExpired = false;
|
||||
startMutation(d);
|
||||
} else {
|
||||
isExpired = true;
|
||||
stopMutation(d);
|
||||
}
|
||||
isEnabled = !!enable;
|
||||
},
|
||||
|
||||
// expire complete cache
|
||||
// can be invoked by Mutation Events or
|
||||
// programmatically by other code/scripts
|
||||
// document context is mandatory no checks
|
||||
expireCache =
|
||||
function(d) {
|
||||
isExpired = true;
|
||||
Contexts = global.Object();
|
||||
Results = global.Object();
|
||||
};
|
||||
|
||||
if (!NATIVE_MUTATION_EVENTS && root.addEventListener && Element && Element.prototype) {
|
||||
if (mutationTest('DOMNodeInserted', function(e) { e.appendChild(document.createElement('div')); }) &&
|
||||
mutationTest('DOMNodeRemoved', function(e) { e.removeChild(e.appendChild(document.createElement('div'))); })) {
|
||||
HACKED_MUTATION_EVENTS = true;
|
||||
Element.prototype._setAttribute = Element.prototype.setAttribute;
|
||||
Element.prototype.setAttribute =
|
||||
function(name, val) {
|
||||
this._setAttribute(name, val);
|
||||
mutationWrapper({
|
||||
target: this,
|
||||
type: 'DOMAttrModified',
|
||||
attrName: name,
|
||||
attrValue: val });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
isEnabled = NATIVE_MUTATION_EVENTS || HACKED_MUTATION_EVENTS;
|
||||
|
||||
/*------------------------------- PUBLIC API -------------------------------*/
|
||||
|
||||
// save results into cache
|
||||
Dom.saveResults = saveResults;
|
||||
|
||||
// load results from cache
|
||||
Dom.loadResults = loadResults;
|
||||
|
||||
// expire DOM tree cache
|
||||
Dom.expireCache = expireCache;
|
||||
|
||||
// enable/disable cache
|
||||
Dom.setCache = setCache;
|
||||
|
||||
})(this);
|
||||
126
node_modules/nwmatcher/src/modules/nwmatcher-jquery.js
generated
vendored
Normal file
126
node_modules/nwmatcher/src/modules/nwmatcher-jquery.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* this is just a small example to show
|
||||
* how an extension for NWMatcher could be
|
||||
* adapted to handle special jQuery selectors
|
||||
*
|
||||
* Child Selectors
|
||||
* :even, :odd, :eq, :lt, :gt, :first, :last, :nth
|
||||
*
|
||||
* Pseudo Selectors
|
||||
* :has, :button, :header, :input, :checkbox, :radio, :file, :image
|
||||
* :password, :reset, :submit, :text, :hidden, :visible, :parent
|
||||
*
|
||||
*/
|
||||
|
||||
// for structural pseudo-classes extensions
|
||||
NW.Dom.registerSelector(
|
||||
'jquery:child',
|
||||
/^\:((?:(nth|eq|lt|gt)\(([^()]*)\))|(?:even|odd|first|last))(.*)/i,
|
||||
(function(global) {
|
||||
|
||||
return function(match, source, selector) {
|
||||
|
||||
var status = true, ACCEPT_NODE = NW.Dom.ACCEPT_NODE;
|
||||
|
||||
switch (match[1].toLowerCase()) {
|
||||
case 'odd':
|
||||
source = source.replace(ACCEPT_NODE, 'if((x=x^1)==0){' + ACCEPT_NODE + '}');
|
||||
break;
|
||||
case 'even':
|
||||
source = source.replace(ACCEPT_NODE, 'if((x=x^1)==1){' + ACCEPT_NODE + '}');
|
||||
break;
|
||||
case 'first':
|
||||
source = 'n=h.getElementsByTagName(e.nodeName);if(n.length&&n[0]===e){' + source + '}';
|
||||
break;
|
||||
case 'last':
|
||||
source = 'n=h.getElementsByTagName(e.nodeName);if(n.length&&n[n.length-1]===e){' + source + '}';
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
// compiler will add this to "source"
|
||||
return global.Object({
|
||||
'source': source,
|
||||
'status': status
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})(this));
|
||||
|
||||
// for element pseudo-classes extensions
|
||||
NW.Dom.registerSelector(
|
||||
'jquery:pseudo',
|
||||
/^\:(has|checkbox|file|image|password|radio|reset|submit|text|button|input|header|hidden|visible|parent)(?:\(\s*(["']*)?([^'"()]*)\2\s*\))?(.*)/i,
|
||||
(function(global) {
|
||||
|
||||
return function(match, source) {
|
||||
|
||||
var status = true, ACCEPT_NODE = NW.Dom.ACCEPT_NODE;
|
||||
|
||||
switch(match[1].toLowerCase()) {
|
||||
case 'has':
|
||||
source = source.replace(ACCEPT_NODE, 'if(e.getElementsByTagName("' + match[3].replace(/^\s|\s$/g, '') + '")[0]){' + ACCEPT_NODE + '}');
|
||||
break;
|
||||
case 'checkbox':
|
||||
case 'file':
|
||||
case 'image':
|
||||
case 'password':
|
||||
case 'radio':
|
||||
case 'reset':
|
||||
case 'submit':
|
||||
case 'text':
|
||||
// :checkbox, :file, :image, :password, :radio, :reset, :submit, :text
|
||||
source = 'if(/^' + match[1] + '$/i.test(e.type)){' + source + '}';
|
||||
break;
|
||||
case 'button':
|
||||
case 'input':
|
||||
source = 'if(e.type||/button/i.test(e.nodeName)){' + source + '}';
|
||||
break;
|
||||
case 'header':
|
||||
source = 'if(/h[1-6]/i.test(e.nodeName)){' + source + '}';
|
||||
break;
|
||||
case 'hidden':
|
||||
source = 'if(!e.offsetWidth&&!e.offsetHeight){' + source + '}';
|
||||
break;
|
||||
case 'visible':
|
||||
source = 'if(e.offsetWidth||e.offsetHeight){' + source + '}';
|
||||
break;
|
||||
case 'parent':
|
||||
source += 'if(e.firstChild){' + source + '}';
|
||||
break;
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// compiler will add this to "source"
|
||||
return global.Object({
|
||||
'source': source,
|
||||
'status': status
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})(this));
|
||||
273
node_modules/nwmatcher/src/modules/nwmatcher-pseudos.js
generated
vendored
Normal file
273
node_modules/nwmatcher/src/modules/nwmatcher-pseudos.js
generated
vendored
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* CSS3 pseudo-classes extension for NWMatcher
|
||||
*
|
||||
* Added capabilities:
|
||||
*
|
||||
* - structural pseudo-classes
|
||||
*
|
||||
* :root, :empty,
|
||||
* :nth-child(), nth-of-type(),
|
||||
* :nth-last-child(), nth-last-of-type(),
|
||||
* :first-child, :last-child, :only-child
|
||||
* :first-of-type, :last-of-type, :only-of-type
|
||||
*
|
||||
* - negation, language, target and UI element pseudo-classes
|
||||
*
|
||||
* :not(), :target, :lang(), :target
|
||||
* :link, :visited, :active, :focus, :hover,
|
||||
* :checked, :disabled, :enabled, :selected
|
||||
*/
|
||||
|
||||
(function(global) {
|
||||
|
||||
var LINK_NODES = global.Object({
|
||||
'a': 1, 'A': 1,
|
||||
'area': 1, 'AREA': 1,
|
||||
'link': 1, 'LINK': 1
|
||||
}),
|
||||
|
||||
root = document.documentElement,
|
||||
|
||||
contains = 'compareDocumentPosition' in root ?
|
||||
function(container, element) {
|
||||
return (container.compareDocumentPosition(element) & 16) == 16;
|
||||
} : 'contains' in root ?
|
||||
function(container, element) {
|
||||
return element.nodeType == 1 && container.contains(element);
|
||||
} :
|
||||
function(container, element) {
|
||||
while ((element = element.parentNode) && element.nodeType == 1) {
|
||||
if (element === container) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
isLink =
|
||||
function(element) {
|
||||
return element.getAttribute('href') && LINK_NODES[element.nodeName];
|
||||
},
|
||||
|
||||
isEmpty =
|
||||
function(node) {
|
||||
node = node.firstChild;
|
||||
while (node) {
|
||||
if (node.nodeType == 3 || node.nodeName > '@') return false;
|
||||
node = node.nextSibling;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
nthElement =
|
||||
function(element, last) {
|
||||
var count = 1, succ = last ? 'nextSibling' : 'previousSibling';
|
||||
while ((element = element[succ])) {
|
||||
if (element.nodeName > '@') ++count;
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
nthOfType =
|
||||
function(element, last) {
|
||||
var count = 1, succ = last ? 'nextSibling' : 'previousSibling', type = element.nodeName;
|
||||
while ((element = element[succ])) {
|
||||
if (element.nodeName == type) ++count;
|
||||
}
|
||||
return count;
|
||||
};
|
||||
|
||||
NW.Dom.Snapshot['contains'] = contains;
|
||||
|
||||
NW.Dom.Snapshot['isLink'] = isLink;
|
||||
NW.Dom.Snapshot['isEmpty'] = isEmpty;
|
||||
NW.Dom.Snapshot['nthOfType'] = nthOfType;
|
||||
NW.Dom.Snapshot['nthElement'] = nthElement;
|
||||
|
||||
})(this);
|
||||
|
||||
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(global) {
|
||||
|
||||
return function(match, source) {
|
||||
|
||||
var a, n, b, status = true, test, type;
|
||||
|
||||
switch (match[1]) {
|
||||
|
||||
case 'root':
|
||||
if (match[3])
|
||||
source = 'if(e===h||s.contains(h,e)){' + source + '}';
|
||||
else
|
||||
source = 'if(e===h){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'empty':
|
||||
source = 'if(s.isEmpty(e)){' + source + '}';
|
||||
break;
|
||||
|
||||
default:
|
||||
if (match[1] && match[2]) {
|
||||
|
||||
if (match[2] == 'n') {
|
||||
source = 'if(e!==h){' + source + '}';
|
||||
break;
|
||||
} else if (match[2] == 'even') {
|
||||
a = 2;
|
||||
b = 0;
|
||||
} else if (match[2] == 'odd') {
|
||||
a = 2;
|
||||
b = 1;
|
||||
} else {
|
||||
b = ((n = match[2].match(/(-?\d+)$/)) ? global.parseInt(n[1], 10) : 0);
|
||||
a = ((n = match[2].match(/(-?\d*)n/i)) ? global.parseInt(n[1], 10) : 0);
|
||||
if (n && n[1] == '-') a = -1;
|
||||
}
|
||||
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 : a == -1 ? 'n<=' + b : 'n>=' + b;
|
||||
source =
|
||||
'if(e!==h){' +
|
||||
'n=s[' + (/-of-type/i.test(match[1]) ? '"nthOfType"' : '"nthElement"') + ']' +
|
||||
'(e,' + (/last/i.test(match[1]) ? 'true' : 'false') + ');' +
|
||||
'if(' + test + '){' + source + '}' +
|
||||
'}';
|
||||
|
||||
} else if (match[1]) {
|
||||
|
||||
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){' +
|
||||
( 'n=e;while((n=n.' + a + 'Sibling)' + type + ');if(!n){' + (b ? source :
|
||||
'n=e;while((n=n.' + n + 'Sibling)' + type + ');if(!n){' + source + '}') + '}' ) + '}';
|
||||
|
||||
} else {
|
||||
|
||||
status = false;
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return global.Object({
|
||||
'source': source,
|
||||
'status': status
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})(this));
|
||||
|
||||
NW.Dom.registerSelector(
|
||||
'nwmatcher:dpseudos',
|
||||
/^\:(link|visited|target|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(([^()]*|.*)\))?(.*)/i,
|
||||
(function(global) {
|
||||
|
||||
var doc = global.document,
|
||||
Config = NW.Dom.Config,
|
||||
Tokens = NW.Dom.Tokens,
|
||||
|
||||
reTrimSpace = global.RegExp('^\\s+|\\s+$', 'g'),
|
||||
|
||||
reSimpleNot = global.RegExp('^((?!:not)' +
|
||||
'(' + Tokens.prefixes + '|' + Tokens.identifier +
|
||||
'|\\([^()]*\\))+|\\[' + Tokens.attributes + '\\])$');
|
||||
|
||||
return function(match, source) {
|
||||
|
||||
var expr, status = true, test;
|
||||
|
||||
switch (match[1].match(/^\w+/)[0]) {
|
||||
|
||||
case 'not':
|
||||
expr = match[3].replace(reTrimSpace, '');
|
||||
if (Config.SIMPLENOT && !reSimpleNot.test(expr)) {
|
||||
NW.Dom.emit('Negation pseudo-class only accepts simple selectors "' + match.join('') + '"');
|
||||
} else {
|
||||
if ('compatMode' in doc) {
|
||||
source = 'if(!' + NW.Dom.compile(expr, '', false) + '(e,s,r,d,h,g)){' + source + '}';
|
||||
} else {
|
||||
source = 'if(!s.match(e, "' + expr.replace(/\x22/g, '\\"') + '",g)){' + source +'}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'checked':
|
||||
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"' +
|
||||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') +
|
||||
')||s.isLink(e))&&e.disabled===true){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'enabled':
|
||||
source = 'if(((typeof e.form!=="undefined"' +
|
||||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') +
|
||||
')||s.isLink(e))&&e.disabled===false){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'lang':
|
||||
test = '';
|
||||
if (match[2]) test = match[2].substr(0, 2) + '-';
|
||||
source = 'do{(n=e.lang||"").toLowerCase();' +
|
||||
'if((n==""&&h.lang=="' + match[2].toLowerCase() + '")||' +
|
||||
'(n&&(n=="' + match[2].toLowerCase() +
|
||||
'"||n.substr(0,3)=="' + test.toLowerCase() + '")))' +
|
||||
'{' + source + 'break;}}while((e=e.parentNode)&&e!==g);';
|
||||
break;
|
||||
|
||||
case 'target':
|
||||
source = 'if(e.id==d.location.hash.slice(1)){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
source = 'if(s.isLink(e)&&!e.visited){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'visited':
|
||||
source = 'if(s.isLink(e)&&e.visited){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'active':
|
||||
source = 'if(e===d.activeElement){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'hover':
|
||||
source = 'if(e===d.hoverElement){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'focus':
|
||||
source = 'hasFocus' in doc ?
|
||||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href||typeof e.tabIndex=="number")){' + source + '}' :
|
||||
'if(e===d.activeElement&&(e.type||e.href)){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'selected':
|
||||
source = 'if(/^option$/i.test(e.nodeName)&&(e.selected||e.checked)){' + source + '}';
|
||||
break;
|
||||
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return global.Object({
|
||||
'source': source,
|
||||
'status': status
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})(this));
|
||||
35
node_modules/nwmatcher/src/modules/nwmatcher-shortcuts.js
generated
vendored
Normal file
35
node_modules/nwmatcher/src/modules/nwmatcher-shortcuts.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
NW.Dom.shortcuts = (function() {
|
||||
|
||||
// match missing R/L context
|
||||
var nextID = 0,
|
||||
reLeftContext = /^[\x20\t\n\r\f]*[>+~]/,
|
||||
reRightContext = /[>+~][\x20\t\n\r\f]*$/;
|
||||
|
||||
return function(selector, from, alt) {
|
||||
|
||||
// add left context if missing
|
||||
if (reLeftContext.test(selector)) {
|
||||
if (from.nodeType == 9) {
|
||||
selector = '* ' + selector;
|
||||
} else if (/html|body/i.test(from.nodeName)) {
|
||||
selector = from.nodeName + ' ' + selector;
|
||||
} else if (alt) {
|
||||
selector = NW.Dom.shortcuts(selector, alt);
|
||||
} else if (from.nodeType == 1 && from.id) {
|
||||
selector = '#' + from.id + ' ' + selector;
|
||||
} else {
|
||||
++nextID;
|
||||
selector = '#' + (from.id = 'NW' + nextID) + ' ' + selector;
|
||||
//NW.Dom.emit('Unable to resolve a context for the shortcut selector "' + selector + '"');
|
||||
}
|
||||
}
|
||||
|
||||
// add right context if missing
|
||||
if (reRightContext.test(selector)) {
|
||||
selector += ' *';
|
||||
}
|
||||
|
||||
return selector;
|
||||
};
|
||||
|
||||
})();
|
||||
90
node_modules/nwmatcher/src/modules/nwmatcher-traversal.js
generated
vendored
Normal file
90
node_modules/nwmatcher/src/modules/nwmatcher-traversal.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Element Traversal methods from Juriy Zaytsev (kangax)
|
||||
* used to emulate Prototype up/down/previous/next methods
|
||||
*/
|
||||
|
||||
(function(D){
|
||||
|
||||
// TODO: all of this needs tests
|
||||
var match = D.match, select = D.select, root = document.documentElement,
|
||||
|
||||
// Use the Element Traversal API if available.
|
||||
nextElement = 'nextElementSibling',
|
||||
previousElement = 'previousElementSibling',
|
||||
parentElement = 'parentElement';
|
||||
|
||||
// Fall back to the DOM Level 1 API.
|
||||
if (!(nextElement in root)) nextElement = 'nextSibling';
|
||||
if (!(previousElement in root)) previousElement = 'previousSibling';
|
||||
if (!(parentElement in root)) parentElement = 'parentNode';
|
||||
|
||||
function walkElements(property, element, expr) {
|
||||
var i = 0, isIndex = typeof expr == 'number';
|
||||
if (typeof expr == 'undefined') {
|
||||
isIndex = true;
|
||||
expr = 0;
|
||||
}
|
||||
while ((element = element[property])) {
|
||||
if (element.nodeType != 1) continue;
|
||||
if (isIndex) {
|
||||
++i;
|
||||
if (i == expr) return element;
|
||||
} else if (match(element, expr)) {
|
||||
return element;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method up
|
||||
* @param {HTMLElement} element element to walk from
|
||||
* @param {String | Number} expr CSS expression or an index
|
||||
* @return {HTMLElement | null}
|
||||
*/
|
||||
function up(element, expr) {
|
||||
return walkElements(parentElement, element, expr);
|
||||
}
|
||||
/**
|
||||
* @method next
|
||||
* @param {HTMLElement} element element to walk from
|
||||
* @param {String | Number} expr CSS expression or an index
|
||||
* @return {HTMLElement | null}
|
||||
*/
|
||||
function next(element, expr) {
|
||||
return walkElements(nextElement, element, expr);
|
||||
}
|
||||
/**
|
||||
* @method previous
|
||||
* @param {HTMLElement} element element to walk from
|
||||
* @param {String | Number} expr CSS expression or an index
|
||||
* @return {HTMLElement | null}
|
||||
*/
|
||||
function previous(element, expr) {
|
||||
return walkElements(previousElement, element, expr);
|
||||
}
|
||||
/**
|
||||
* @method down
|
||||
* @param {HTMLElement} element element to walk from
|
||||
* @param {String | Number} expr CSS expression or an index
|
||||
* @return {HTMLElement | null}
|
||||
*/
|
||||
function down(element, expr) {
|
||||
var isIndex = typeof expr == 'number', descendants, index, descendant;
|
||||
if (expr === null) {
|
||||
element = element.firstChild;
|
||||
while (element && element.nodeType != 1) element = element[nextElement];
|
||||
return element;
|
||||
}
|
||||
if (!isIndex && match(element, expr) || isIndex && expr === 0) return element;
|
||||
descendants = select('*', element);
|
||||
if (isIndex) return descendants[expr] || null;
|
||||
index = 0;
|
||||
while ((descendant = descendants[index]) && !match(descendant, expr)) { ++index; }
|
||||
return descendant || null;
|
||||
}
|
||||
D.up = up;
|
||||
D.down = down;
|
||||
D.next = next;
|
||||
D.previous = previous;
|
||||
})(NW.Dom);
|
||||
104
node_modules/nwmatcher/src/modules/nwmatcher-webforms.js
generated
vendored
Normal file
104
node_modules/nwmatcher/src/modules/nwmatcher-webforms.js
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* this is just a small example to show
|
||||
* how an extension for NWMatcher could be
|
||||
* adapted to handle WebForms/HTML5 selectors
|
||||
*
|
||||
* Pseudo Selectors
|
||||
* :default, :indeterminate, :optional, :required,
|
||||
* :valid, :invalid, :in-range, :out-of-range,
|
||||
* :read-only, :read-write
|
||||
* :has, :matches (not yet in a defined specification)
|
||||
*
|
||||
*/
|
||||
|
||||
// for UI pseudo-classes extensions (WebForms/HTML5)
|
||||
NW.Dom.registerSelector(
|
||||
'html5:pseudos',
|
||||
/^\:(default|indeterminate|optional|required|valid|invalid|in-range|out-of-range|read-only|read-write)(.*)/,
|
||||
(function(global) {
|
||||
|
||||
return function(match, source) {
|
||||
|
||||
var status = true,
|
||||
|
||||
HTML5PseudoClasses = global.Object({
|
||||
'default': 4, 'indeterminate': 4, 'invalid': 4, 'valid': 4,
|
||||
'optional': 4, 'required': 4, 'read-write': 4, 'read-only': 4
|
||||
});
|
||||
|
||||
switch (match[1]) {
|
||||
|
||||
// HTML5 UI element states (form controls)
|
||||
case 'default':
|
||||
// only radio buttons, check boxes and option elements
|
||||
source = 'if(((typeof e.form!=="undefined"&&(/radio|checkbox/i).test(e.type))||/option/i.test(e.nodeName))&&(e.defaultChecked||e.defaultSelected)){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'indeterminate':
|
||||
// only radio buttons, check boxes and option elements
|
||||
source = 'if(typeof e.form!=="undefined"&&(/radio|checkbox/i).test(e.type)&&s.select("[checked]",e.form).length===0){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'optional':
|
||||
// only fields for which "required" applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.required!="undefined"&&!e.required){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'required':
|
||||
// only fields for which "required" applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.required!="undefined"&&e.required){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'read-write':
|
||||
// only fields for which "readOnly" applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.readOnly!="undefined"&&!e.readOnly){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'read-only':
|
||||
// only fields for which "readOnly" applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.readOnly!="undefined"&&e.readOnly){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'invalid':
|
||||
// only fields for which validity applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.validity=="object"&&!e.validity.valid){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'valid':
|
||||
// only fields for which validity applies
|
||||
source = 'if(typeof e.form!=="undefined"&&typeof e.validity=="object"&&e.validity.valid){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'in-range':
|
||||
// only fields for which validity applies
|
||||
source = 'if(typeof e.form!=="undefined"&&' +
|
||||
'(s.getAttribute(e,"min")||s.getAttribute(e,"max"))&&' +
|
||||
'typeof e.validity=="object"&&!e.validity.typeMismatch&&' +
|
||||
'!e.validity.rangeUnderflow&&!e.validity.rangeOverflow){' + source + '}';
|
||||
break;
|
||||
|
||||
case 'out-of-range':
|
||||
// only fields for which validity applies
|
||||
source = 'if(typeof e.form!=="undefined"&&' +
|
||||
'(s.getAttribute(e,"min")||s.getAttribute(e,"max"))&&' +
|
||||
'typeof e.validity=="object"&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)){' + source + '}';
|
||||
break;
|
||||
|
||||
default:
|
||||
status = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
// compiler will add this to "source"
|
||||
return global.Object({
|
||||
'source': source,
|
||||
'status': status
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
})(this));
|
||||
744
node_modules/nwmatcher/src/nwmatcher-base.js
generated
vendored
Normal file
744
node_modules/nwmatcher/src/nwmatcher-base.js
generated
vendored
Normal file
@@ -0,0 +1,744 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* nwmatcher-base.js - A fast CSS selector engine and matcher
|
||||
*
|
||||
* Author: Diego Perini <diego.perini at gmail com>
|
||||
* Version: 1.3.7
|
||||
* Created: 20070722
|
||||
* Release: 20151120
|
||||
*
|
||||
* License:
|
||||
* http://javascript.nwbox.com/NWMatcher/MIT-LICENSE
|
||||
* Download:
|
||||
* http://javascript.nwbox.com/NWMatcher/nwmatcher.js
|
||||
*/
|
||||
|
||||
(function(global, factory) {
|
||||
|
||||
if (typeof module == 'object' && typeof exports == 'object') {
|
||||
module.exports = function (browserGlobal) {
|
||||
// passed global does not contain
|
||||
// references to native objects
|
||||
browserGlobal.console = console;
|
||||
browserGlobal.parseInt = parseInt;
|
||||
browserGlobal.Function = Function;
|
||||
browserGlobal.Boolean = Boolean;
|
||||
browserGlobal.Number = Number;
|
||||
browserGlobal.RegExp = RegExp;
|
||||
browserGlobal.String = String;
|
||||
browserGlobal.Object = Object;
|
||||
browserGlobal.Array = Array;
|
||||
browserGlobal.Error = Error;
|
||||
browserGlobal.Date = Date;
|
||||
browserGlobal.Math = Math;
|
||||
var exports = browserGlobal.Object();
|
||||
factory(browserGlobal, exports);
|
||||
return exports;
|
||||
};
|
||||
module.factory = factory;
|
||||
} else {
|
||||
factory(global,
|
||||
(global.NW || (global.NW = global.Object())) &&
|
||||
(global.NW.Dom || (global.NW.Dom = global.Object())));
|
||||
global.NW.Dom.factory = factory;
|
||||
}
|
||||
|
||||
})(this, function(global, exports) {
|
||||
|
||||
var version = 'nwmatcher-1.3.7',
|
||||
|
||||
Dom = exports,
|
||||
|
||||
doc = global.document,
|
||||
root = doc.documentElement,
|
||||
|
||||
slice = global.Array.slice,
|
||||
|
||||
isSingleMatch,
|
||||
isSingleSelect,
|
||||
|
||||
lastSlice,
|
||||
lastContext,
|
||||
lastPosition,
|
||||
|
||||
lastMatcher,
|
||||
lastSelector,
|
||||
|
||||
lastPartsMatch,
|
||||
lastPartsSelect,
|
||||
|
||||
prefixes = '[#.:]?',
|
||||
operators = '([~*^$|!]?={1})',
|
||||
whitespace = '[\\x20\\t\\n\\r\\f]*',
|
||||
combinators = '[\\x20]|[>+~](?=[^>+~])',
|
||||
pseudoparms = '(?:[-+]?\\d*n)?[-+]?\\d*',
|
||||
|
||||
quotedvalue = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"' + "|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'",
|
||||
skipgroup = '\\[.*\\]|\\(.*\\)|\\{.*\\}',
|
||||
|
||||
encoding = '(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',
|
||||
identifier = '(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',
|
||||
|
||||
attrcheck = '(' + quotedvalue + '|' + identifier + ')',
|
||||
attributes = whitespace + '(' + encoding + '*:?' + encoding + '+)' +
|
||||
whitespace + '(?:' + operators + whitespace + attrcheck + ')?' + whitespace,
|
||||
|
||||
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),
|
||||
|
||||
pseudoclass = '((?:' +
|
||||
pseudoparms + '|' + quotedvalue + '|' +
|
||||
prefixes + '|' + encoding + '+|' +
|
||||
'\\[' + attributes + '\\]|' +
|
||||
'\\(.+\\)|' + whitespace + '|' +
|
||||
',)+)',
|
||||
|
||||
extensions = '.+',
|
||||
|
||||
standardValidator =
|
||||
'(?=[\\x20\\t\\n\\r\\f]*[^>+~(){}<>])' +
|
||||
'(' +
|
||||
'\\*' +
|
||||
'|(?:' + prefixes + identifier + ')' +
|
||||
'|' + combinators +
|
||||
'|\\[' + attributes + '\\]' +
|
||||
'|\\(' + pseudoclass + '\\)' +
|
||||
'|\\{' + extensions + '\\}' +
|
||||
'|(?:,|' + whitespace + ')' +
|
||||
')+',
|
||||
|
||||
extendedValidator = standardValidator.replace(pseudoclass, '.*'),
|
||||
|
||||
reValidator = global.RegExp(standardValidator),
|
||||
|
||||
reTrimSpaces = global.RegExp('^' +
|
||||
whitespace + '|' + whitespace + '$', 'g'),
|
||||
|
||||
reSplitGroup = global.RegExp('(' +
|
||||
'[^,\\\\()[\\]]+' +
|
||||
'|\\[[^[\\]]*\\]|\\[.*\\]' +
|
||||
'|\\([^()]+\\)|\\(.*\\)' +
|
||||
'|\\{[^{}]+\\}|\\{.*\\}' +
|
||||
'|\\\\.' +
|
||||
')+', 'g'),
|
||||
|
||||
reSplitToken = global.RegExp('(' +
|
||||
'\\[' + attributes + '\\]|' +
|
||||
'\\(' + pseudoclass + '\\)|' +
|
||||
'\\\\.|[^\\x20\\t\\n\\r\\f>+~])+', 'g'),
|
||||
|
||||
reWhiteSpace = /[\x20\t\n\r\f]+/g,
|
||||
|
||||
reOptimizeSelector = global.RegExp(identifier + '|^$'),
|
||||
|
||||
ATTR_BOOLEAN = global.Object({
|
||||
checked: 1, disabled: 1, ismap: 1,
|
||||
multiple: 1, readonly: 1, selected: 1
|
||||
}),
|
||||
|
||||
ATTR_DEFAULT = global.Object({
|
||||
value: 'defaultValue',
|
||||
checked: 'defaultChecked',
|
||||
selected: 'defaultSelected'
|
||||
}),
|
||||
|
||||
ATTR_URIDATA = global.Object({
|
||||
action: 2, cite: 2, codebase: 2, data: 2, href: 2,
|
||||
longdesc: 2, lowsrc: 2, src: 2, usemap: 2
|
||||
}),
|
||||
|
||||
Selectors = global.Object(),
|
||||
|
||||
Operators = global.Object({
|
||||
'=': "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'"
|
||||
}),
|
||||
|
||||
Optimize = global.Object({
|
||||
ID: global.RegExp('^\\*?#(' + encoding + '+)|' + skipgroup),
|
||||
TAG: global.RegExp('^(' + encoding + '+)|' + skipgroup),
|
||||
CLASS: global.RegExp('^\\*?\\.(' + encoding + '+$)|' + skipgroup)
|
||||
}),
|
||||
|
||||
Patterns = global.Object({
|
||||
universal: /^\*(.*)/,
|
||||
id: global.RegExp('^#(' + encoding + '+)(.*)'),
|
||||
tagName: global.RegExp('^(' + encoding + '+)(.*)'),
|
||||
className: global.RegExp('^\\.(' + encoding + '+)(.*)'),
|
||||
attribute: global.RegExp('^\\[' + attrmatcher + '\\](.*)'),
|
||||
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]+(.*)/
|
||||
}),
|
||||
|
||||
QUIRKS_MODE,
|
||||
XML_DOCUMENT,
|
||||
|
||||
GEBTN = 'getElementsByTagName' in doc,
|
||||
GEBCN = 'getElementsByClassName' in doc,
|
||||
|
||||
IE_LT_9 = typeof doc.addEventListener != 'function',
|
||||
|
||||
INSENSITIVE_MAP = global.Object({
|
||||
'href': 1, 'lang': 1, 'src': 1, 'style': 1, 'title': 1,
|
||||
'type': 1, 'xmlns': 1, 'xml:lang': 1, 'xml:space': 1
|
||||
}),
|
||||
|
||||
TO_UPPER_CASE = IE_LT_9 ? '.toUpperCase()' : '',
|
||||
|
||||
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;' : '',
|
||||
|
||||
Config = global.Object({
|
||||
CACHING: false,
|
||||
SIMPLENOT: true,
|
||||
UNIQUE_ID: true,
|
||||
USE_HTML5: true,
|
||||
VERBOSITY: true
|
||||
}),
|
||||
|
||||
configure =
|
||||
function(option) {
|
||||
if (typeof option == 'string') { return Config[option] || Config; }
|
||||
if (typeof option != 'object') { return false; }
|
||||
for (var i in option) {
|
||||
Config[i] = !!option[i];
|
||||
if (i == 'SIMPLENOT') {
|
||||
matchContexts = global.Object();
|
||||
matchResolvers = global.Object();
|
||||
selectContexts = global.Object();
|
||||
selectResolvers = global.Object();
|
||||
}
|
||||
}
|
||||
reValidator = global.RegExp(Config.SIMPLENOT ?
|
||||
standardValidator : extendedValidator);
|
||||
return true;
|
||||
},
|
||||
|
||||
concatCall =
|
||||
function(data, elements, callback) {
|
||||
var i = -1, element;
|
||||
while ((element = elements[++i])) {
|
||||
if (false === callback(data[data.length] = element)) { break; }
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
emit =
|
||||
function(message) {
|
||||
if (Config.VERBOSITY) { throw global.Error(message); }
|
||||
if (global.console && global.console.log) {
|
||||
global.console.log(message);
|
||||
}
|
||||
},
|
||||
|
||||
switchContext =
|
||||
function(from, force) {
|
||||
var oldDoc = doc;
|
||||
lastContext = from;
|
||||
doc = from.ownerDocument || from;
|
||||
if (force || oldDoc !== doc) {
|
||||
root = doc.documentElement;
|
||||
XML_DOCUMENT = doc.createElement('DiV').nodeName == 'DiV';
|
||||
QUIRKS_MODE = !XML_DOCUMENT &&
|
||||
typeof doc.compatMode == 'string' ?
|
||||
doc.compatMode.indexOf('CSS') < 0 :
|
||||
(function() {
|
||||
var style = doc.createElement('div').style;
|
||||
return style && (style.width = 1) && style.width == '1px';
|
||||
})();
|
||||
|
||||
Config.CACHING && Dom.setCache(true, doc);
|
||||
}
|
||||
},
|
||||
|
||||
convertEscapes =
|
||||
function(str) {
|
||||
return str.replace(/\\([0-9a-fA-F]{1,6}\x20?|.)|([\x22\x27])/g, function(substring, p1, p2) {
|
||||
var codePoint, highHex, highSurrogate, lowHex, lowSurrogate;
|
||||
|
||||
if (p2) {
|
||||
return '\\' + p2;
|
||||
}
|
||||
|
||||
if (/^[0-9a-fA-F]/.test(p1)) {
|
||||
codePoint = parseInt(p1, 16);
|
||||
|
||||
if (codePoint < 0 || codePoint > 0x10ffff) {
|
||||
return '\\ufffd';
|
||||
}
|
||||
|
||||
if (codePoint <= 0xffff) {
|
||||
lowHex = '000' + codePoint.toString(16);
|
||||
return '\\u' + lowHex.substr(lowHex.length - 4);
|
||||
}
|
||||
|
||||
codePoint -= 0x10000;
|
||||
highSurrogate = (codePoint >> 10) + 0xd800;
|
||||
lowSurrogate = (codePoint % 0x400) + 0xdc00;
|
||||
highHex = '000' + highSurrogate.toString(16);
|
||||
lowHex = '000' + lowSurrogate.toString(16);
|
||||
|
||||
return '\\u' + highHex.substr(highHex.length - 4) +
|
||||
'\\u' + lowHex.substr(lowHex.length - 4);
|
||||
}
|
||||
|
||||
if (/^[\\\x22\x27]/.test(p1)) {
|
||||
return substring;
|
||||
}
|
||||
|
||||
return p1;
|
||||
});
|
||||
},
|
||||
|
||||
byIdRaw =
|
||||
function(id, elements) {
|
||||
var i = 0, element = null;
|
||||
while ((element = elements[i])) {
|
||||
if (element.getAttribute('id') == id) {
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
_byId = !('fileSize' in doc) ?
|
||||
function(id, from) {
|
||||
id = id.replace(/\\([^\\]{1})/g, '$1');
|
||||
return from.getElementById && from.getElementById(id) ||
|
||||
byIdRaw(id, from.getElementsByTagName('*'));
|
||||
} :
|
||||
function(id, from) {
|
||||
var element = null;
|
||||
id = id.replace(/\\([^\\]{1})/g, '$1');
|
||||
if (XML_DOCUMENT || from.nodeType != 9) {
|
||||
return byIdRaw(id, from.getElementsByTagName('*'));
|
||||
}
|
||||
if ((element = from.getElementById(id)) &&
|
||||
element.name == id && from.getElementsByName) {
|
||||
return byIdRaw(id, from.getElementsByName(id));
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
byId =
|
||||
function(id, from) {
|
||||
from || (from = doc);
|
||||
if (lastContext !== from) { switchContext(from); }
|
||||
return _byId(id, from);
|
||||
},
|
||||
|
||||
byTagRaw =
|
||||
function(tag, from) {
|
||||
var any = tag == '*', element = from, elements = global.Array(), next = element.firstChild;
|
||||
any || (tag = tag.toUpperCase());
|
||||
while ((element = next)) {
|
||||
if (element.tagName > '@' && (any || element.tagName.toUpperCase() == tag)) {
|
||||
elements[elements.length] = element;
|
||||
}
|
||||
if ((next = element.firstChild || element.nextSibling)) continue;
|
||||
while (!next && (element = element.parentNode) && element !== from) {
|
||||
next = element.nextSibling;
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
},
|
||||
|
||||
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) :
|
||||
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) {
|
||||
var obj = node.getAttributeNode(attribute = attribute.toLowerCase());
|
||||
return ATTR_DEFAULT[attribute] && attribute != 'value' ?
|
||||
node[ATTR_DEFAULT[attribute]] : obj && obj.specified;
|
||||
},
|
||||
|
||||
compile =
|
||||
function(selector, source, mode) {
|
||||
|
||||
var parts = typeof selector == 'string' ? selector.match(reSplitGroup) : selector;
|
||||
|
||||
typeof source == 'string' || (source = '');
|
||||
|
||||
if (parts.length == 1) {
|
||||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode);
|
||||
} else {
|
||||
var i = -1, seen = global.Object(), token;
|
||||
while ((token = parts[++i])) {
|
||||
token = token.replace(reTrimSpaces, '');
|
||||
if (!seen[token] && (seen[token] = true)) {
|
||||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode)
|
||||
return global.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 global.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, mode) {
|
||||
|
||||
var k = 0, expr, match, name, result, status, test, type;
|
||||
|
||||
while (selector) {
|
||||
|
||||
k++;
|
||||
|
||||
if ((match = selector.match(Patterns.universal))) {
|
||||
expr = '';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.id))) {
|
||||
source = 'if(' + (XML_DOCUMENT ?
|
||||
's.getAttribute(e,"id")' :
|
||||
'(e.submit?s.getAttribute(e,"id"):e.id)') +
|
||||
'=="' + match[1] + '"' +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.tagName))) {
|
||||
source = 'if(e.nodeName' + (XML_DOCUMENT ?
|
||||
'=="' + match[1] + '"' : TO_UPPER_CASE +
|
||||
'=="' + match[1].toUpperCase() + '"') +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.className))) {
|
||||
source = 'if((n=' + (XML_DOCUMENT ?
|
||||
'e.getAttribute("class")' : 'e.className') +
|
||||
')&&n.length&&(" "+' + (QUIRKS_MODE ? 'n.toLowerCase()' : 'n') +
|
||||
'.replace(' + reWhiteSpace + '," ")+" ").indexOf(" ' +
|
||||
(QUIRKS_MODE ? match[1].toLowerCase() : match[1]) + ' ")>-1' +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.attribute))) {
|
||||
if (match[2] && !Operators[match[2]]) {
|
||||
emit('Unsupported operator in attribute selectors "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
test = 'false';
|
||||
if (match[2] && match[4] && (test = Operators[match[2]])) {
|
||||
match[4] = convertEscapes(match[4]);
|
||||
type = INSENSITIVE_MAP[match[1].toLowerCase()];
|
||||
test = test.replace(/\%m/g, type ? match[4].toLowerCase() : match[4]);
|
||||
} else if (match[2] == '!=' || match[2] == '=') {
|
||||
test = 'n' + match[2] + '=""';
|
||||
}
|
||||
source = 'if(n=s.hasAttribute(e,"' + match[1] + '")){' +
|
||||
(match[2] ? 'n=s.getAttribute(e,"' + match[1] + '")' : '') +
|
||||
(type && match[2] ? '.toLowerCase();' : ';') +
|
||||
'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 + ';';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.relative))) {
|
||||
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 = (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 + ';';
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
expr = false;
|
||||
status = false;
|
||||
for (expr in Selectors) {
|
||||
if ((match = selector.match(Selectors[expr].Expression)) && match[1]) {
|
||||
result = Selectors[expr].Callback(match, source);
|
||||
source = result.source;
|
||||
status = result.status;
|
||||
if (status) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
emit('Unknown pseudo-class selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!expr) {
|
||||
emit('Unknown token in selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
emit('Invalid syntax in selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
selector = match && match[match.length - 1];
|
||||
}
|
||||
|
||||
return source;
|
||||
},
|
||||
|
||||
match =
|
||||
function(element, selector, from, callback) {
|
||||
|
||||
var parts;
|
||||
|
||||
if (!(element && element.nodeType == 1)) {
|
||||
emit('Invalid element argument');
|
||||
return false;
|
||||
} else if (typeof selector != 'string') {
|
||||
emit('Invalid selector argument');
|
||||
return false;
|
||||
} else if (lastContext !== from) {
|
||||
switchContext(from || (from = element.ownerDocument));
|
||||
}
|
||||
|
||||
selector = selector.replace(reTrimSpaces, '');
|
||||
|
||||
Config.SHORTCUTS && (selector = Dom.shortcuts(selector, element, from));
|
||||
|
||||
if (lastMatcher != selector) {
|
||||
if ((parts = selector.match(reValidator)) && parts[0] == selector) {
|
||||
isSingleMatch = (parts = selector.match(reSplitGroup)).length < 2;
|
||||
lastMatcher = selector;
|
||||
lastPartsMatch = parts;
|
||||
} else {
|
||||
emit('The string "' + selector + '", is not a valid CSS selector');
|
||||
return false;
|
||||
}
|
||||
} else parts = lastPartsMatch;
|
||||
|
||||
if (!matchResolvers[selector] || matchContexts[selector] !== from) {
|
||||
matchResolvers[selector] = compile(isSingleMatch ? [selector] : parts, '', false);
|
||||
matchContexts[selector] = from;
|
||||
}
|
||||
|
||||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, { });
|
||||
},
|
||||
|
||||
first =
|
||||
function(selector, from) {
|
||||
return select(selector, from, function() { return false; })[0] || null;
|
||||
},
|
||||
|
||||
select =
|
||||
function(selector, from, callback) {
|
||||
|
||||
var i, changed, element, elements, parts, token, original = selector;
|
||||
|
||||
if (arguments.length === 0) {
|
||||
emit('Not enough arguments');
|
||||
return [ ];
|
||||
} else if (typeof selector != 'string') {
|
||||
return [ ];
|
||||
} else if (from && !(/1|9|11/).test(from.nodeType)) {
|
||||
emit('Invalid or illegal context element');
|
||||
return [ ];
|
||||
} else if (lastContext !== from) {
|
||||
switchContext(from || (from = doc));
|
||||
}
|
||||
|
||||
if (Config.CACHING && (elements = Dom.loadResults(original, from, doc, root))) {
|
||||
return callback ? concatCall([ ], elements, callback) : elements;
|
||||
}
|
||||
|
||||
selector = selector.replace(reTrimSpaces, '');
|
||||
|
||||
Config.SHORTCUTS && (selector = Dom.shortcuts(selector, from));
|
||||
|
||||
if ((changed = lastSelector != selector)) {
|
||||
if ((parts = selector.match(reValidator)) && parts[0] == selector) {
|
||||
isSingleSelect = (parts = selector.match(reSplitGroup)).length < 2;
|
||||
lastSelector = selector;
|
||||
lastPartsSelect = parts;
|
||||
} else {
|
||||
emit('The string "' + selector + '", is not a valid CSS selector');
|
||||
return [ ];
|
||||
}
|
||||
} else parts = lastPartsSelect;
|
||||
|
||||
if (from.nodeType == 11) {
|
||||
|
||||
elements = byTagRaw('*', from);
|
||||
|
||||
} else if (isSingleSelect) {
|
||||
|
||||
if (changed) {
|
||||
parts = selector.match(reSplitToken);
|
||||
token = parts[parts.length - 1];
|
||||
lastSlice = token.split(':not')[0];
|
||||
lastPosition = selector.length - token.length;
|
||||
}
|
||||
|
||||
if (Config.UNIQUE_ID && (parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) {
|
||||
if ((element = _byId(token, from))) {
|
||||
if (match(element, selector)) {
|
||||
callback && callback(element);
|
||||
elements = global.Array(element);
|
||||
} else elements = global.Array();
|
||||
}
|
||||
}
|
||||
|
||||
else if (Config.UNIQUE_ID && (parts = selector.match(Optimize.ID)) && (token = parts[1])) {
|
||||
if ((element = _byId(token, doc))) {
|
||||
if ('#' + token == selector) {
|
||||
callback && callback(element);
|
||||
elements = global.Array(element);
|
||||
} else if (/[>+~]/.test(selector)) {
|
||||
from = element.parentNode;
|
||||
} else {
|
||||
from = element;
|
||||
}
|
||||
} else elements = global.Array();
|
||||
}
|
||||
|
||||
if (elements) {
|
||||
Config.CACHING && Dom.saveResults(original, from, doc, elements);
|
||||
return elements;
|
||||
}
|
||||
|
||||
if (!XML_DOCUMENT && GEBTN && (parts = lastSlice.match(Optimize.TAG)) && (token = parts[1])) {
|
||||
if ((elements = from.getElementsByTagName(token)).length === 0) return [ ];
|
||||
selector = selector.slice(0, lastPosition) + selector.slice(lastPosition).replace(token, '*');
|
||||
}
|
||||
|
||||
else if (!XML_DOCUMENT && GEBCN && (parts = lastSlice.match(Optimize.CLASS)) && (token = parts[1])) {
|
||||
if ((elements = from.getElementsByClassName(token.replace(/\\([^\\]{1})/g, '$1'))).length === 0) return [ ];
|
||||
selector = selector.slice(0, lastPosition) + selector.slice(lastPosition).replace('.' + token,
|
||||
reOptimizeSelector.test(selector.charAt(selector.indexOf(token) - 1)) ? '' : '*');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!elements) {
|
||||
if (IE_LT_9) {
|
||||
elements = /^(?:applet|object)$/i.test(from.nodeName) ?
|
||||
from.childNodes : from.all;
|
||||
} else {
|
||||
elements = from.getElementsByTagName('*');
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectResolvers[selector] || selectContexts[selector] !== from) {
|
||||
selectResolvers[selector] = compile(isSingleSelect ? [selector] : parts, REJECT_NODE, true);
|
||||
selectContexts[selector] = from;
|
||||
}
|
||||
|
||||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, { });
|
||||
|
||||
Config.CACHING && Dom.saveResults(original, from, doc, elements);
|
||||
|
||||
return elements;
|
||||
},
|
||||
|
||||
FN = function(x) { return x; },
|
||||
|
||||
matchContexts = global.Object(),
|
||||
matchResolvers = global.Object(),
|
||||
|
||||
selectContexts = global.Object(),
|
||||
selectResolvers = global.Object(),
|
||||
|
||||
Snapshot = global.Object({
|
||||
byId: _byId,
|
||||
match: match,
|
||||
select: select,
|
||||
getAttribute: getAttribute,
|
||||
hasAttribute: hasAttribute
|
||||
});
|
||||
|
||||
Tokens = global.Object({
|
||||
prefixes: prefixes,
|
||||
encoding: encoding,
|
||||
operators: operators,
|
||||
whitespace: whitespace,
|
||||
identifier: identifier,
|
||||
attributes: attributes,
|
||||
combinators: combinators,
|
||||
pseudoclass: pseudoclass,
|
||||
pseudoparms: pseudoparms,
|
||||
quotedvalue: quotedvalue
|
||||
});
|
||||
|
||||
Dom.ACCEPT_NODE = ACCEPT_NODE;
|
||||
|
||||
Dom.byId = byId;
|
||||
Dom.match = match;
|
||||
Dom.first = first;
|
||||
Dom.select = select;
|
||||
Dom.compile = compile;
|
||||
Dom.configure = configure;
|
||||
|
||||
Dom.setCache = FN;
|
||||
Dom.shortcuts = FN;
|
||||
Dom.loadResults = FN;
|
||||
Dom.saveResults = FN;
|
||||
|
||||
Dom.emit = emit;
|
||||
Dom.Config = Config;
|
||||
Dom.Snapshot = Snapshot;
|
||||
|
||||
Dom.Operators = Operators;
|
||||
Dom.Selectors = Selectors;
|
||||
|
||||
Dom.Tokens = Tokens;
|
||||
Dom.Version = version;
|
||||
|
||||
Dom.registerOperator =
|
||||
function(symbol, resolver) {
|
||||
Operators[symbol] || (Operators[symbol] = resolver);
|
||||
};
|
||||
|
||||
Dom.registerSelector =
|
||||
function(name, rexp, func) {
|
||||
Selectors[name] || (Selectors[name] = global.Object({
|
||||
Expression: rexp,
|
||||
Callback: func
|
||||
}));
|
||||
};
|
||||
|
||||
switchContext(doc, true);
|
||||
|
||||
});
|
||||
903
node_modules/nwmatcher/src/nwmatcher-noqsa.js
generated
vendored
Normal file
903
node_modules/nwmatcher/src/nwmatcher-noqsa.js
generated
vendored
Normal file
@@ -0,0 +1,903 @@
|
||||
/*
|
||||
* Copyright (C) 2007-2015 Diego Perini
|
||||
* All rights reserved.
|
||||
*
|
||||
* nwmatcher-noqsa.js - A fast CSS selector engine and matcher
|
||||
*
|
||||
* Author: Diego Perini <diego.perini at gmail com>
|
||||
* Version: 1.3.7
|
||||
* Created: 20070722
|
||||
* Release: 20151120
|
||||
*
|
||||
* License:
|
||||
* http://javascript.nwbox.com/NWMatcher/MIT-LICENSE
|
||||
* Download:
|
||||
* http://javascript.nwbox.com/NWMatcher/nwmatcher.js
|
||||
*/
|
||||
|
||||
(function(global, factory) {
|
||||
|
||||
if (typeof module == 'object' && typeof exports == 'object') {
|
||||
module.exports = function (browserGlobal) {
|
||||
// passed global does not contain
|
||||
// references to native objects
|
||||
browserGlobal.console = console;
|
||||
browserGlobal.parseInt = parseInt;
|
||||
browserGlobal.Function = Function;
|
||||
browserGlobal.Boolean = Boolean;
|
||||
browserGlobal.Number = Number;
|
||||
browserGlobal.RegExp = RegExp;
|
||||
browserGlobal.String = String;
|
||||
browserGlobal.Object = Object;
|
||||
browserGlobal.Array = Array;
|
||||
browserGlobal.Error = Error;
|
||||
browserGlobal.Date = Date;
|
||||
browserGlobal.Math = Math;
|
||||
var exports = browserGlobal.Object();
|
||||
factory(browserGlobal, exports);
|
||||
return exports;
|
||||
};
|
||||
module.factory = factory;
|
||||
} else {
|
||||
factory(global,
|
||||
(global.NW || (global.NW = global.Object())) &&
|
||||
(global.NW.Dom || (global.NW.Dom = global.Object())));
|
||||
global.NW.Dom.factory = factory;
|
||||
}
|
||||
|
||||
})(this, function(global, exports) {
|
||||
|
||||
var version = 'nwmatcher-1.3.7',
|
||||
|
||||
Dom = exports,
|
||||
|
||||
doc = global.document,
|
||||
root = doc.documentElement,
|
||||
|
||||
isSingleMatch,
|
||||
isSingleSelect,
|
||||
|
||||
lastSlice,
|
||||
lastContext,
|
||||
lastPosition,
|
||||
|
||||
lastMatcher,
|
||||
lastSelector,
|
||||
|
||||
lastPartsMatch,
|
||||
lastPartsSelect,
|
||||
|
||||
operators = '([~*^$|!]?={1})',
|
||||
combinators = '[\\s]|[>+~](?=[^>+~])',
|
||||
pseudoparms = '(?:[-+]?\\d*n)?[-+]?\\d*',
|
||||
|
||||
quotedvalue = '"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"' + "|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'",
|
||||
skipgroup = '\\[.*\\]|\\(.*\\)|\\{.*\\}',
|
||||
|
||||
encoding = '(?:[-\\w]|[^\\x00-\\xa0]|\\\\.)',
|
||||
identifier = '(?:-?[_a-zA-Z]{1}[-\\w]*|[^\\x00-\\xa0]+|\\\\.+)+',
|
||||
|
||||
attrcheck = '(' + quotedvalue + '|' + identifier + ')',
|
||||
attributes = '\\s*(' + encoding + '*:?' + encoding + '+)\\s*(?:' + operators + '\\s*' + attrcheck + ')?\\s*',
|
||||
|
||||
attrmatcher = attributes.replace(attrcheck, '([\\x22\\x27]*)((?:\\\\?.)*?)\\3'),
|
||||
|
||||
pseudoclass = '((?:' +
|
||||
pseudoparms + '|' + quotedvalue + '|' +
|
||||
'[#.:]?|' + encoding + '+|' +
|
||||
'\\[' + attributes + '\\]|' +
|
||||
'\\(.+\\)|\\s*|' +
|
||||
',)+)',
|
||||
|
||||
extensions = '.+',
|
||||
|
||||
standardValidator =
|
||||
'(?=\\s*[^>+~(){}<>])' +
|
||||
'(' +
|
||||
'\\*' +
|
||||
'|(?:[#.:]?' + identifier + ')' +
|
||||
'|' + combinators +
|
||||
'|\\[' + attributes + '\\]' +
|
||||
'|\\(' + pseudoclass + '\\)' +
|
||||
'|\\{' + extensions + '\\}' +
|
||||
'|(?:,|\\s*)' +
|
||||
')+',
|
||||
|
||||
extendedValidator = standardValidator.replace(pseudoclass, '.*'),
|
||||
|
||||
reValidator = global.RegExp(standardValidator),
|
||||
|
||||
reTrimSpaces = /^\s*|\s*$/g,
|
||||
|
||||
reSimpleNot = global.RegExp('^(' +
|
||||
'(?!:not)' +
|
||||
'([#.:]?' +
|
||||
'|' + identifier +
|
||||
'|\\([^()]*\\))+' +
|
||||
'|\\[' + attributes + '\\]' +
|
||||
')$'),
|
||||
|
||||
reSplitGroup = /([^,\\()[\]]+|\[[^[\]]*\]|\[.*\]|\([^()]+\)|\(.*\)|\{[^{}]+\}|\{.*\}|\\.)+/g,
|
||||
|
||||
reSplitToken = global.RegExp('(' +
|
||||
'\\[' + attributes + '\\]|' +
|
||||
'\\(' + pseudoclass + '\\)|' +
|
||||
'\\\\.|[^\\s>+~])+', 'g'),
|
||||
|
||||
reOptimizeSelector = global.RegExp(identifier + '|^$'),
|
||||
|
||||
QUIRKS_MODE,
|
||||
XML_DOCUMENT,
|
||||
|
||||
GEBTN = 'getElementsByTagName' in doc,
|
||||
GEBCN = 'getElementsByClassName' in doc,
|
||||
|
||||
LINK_NODES = global.Object({ a: 1, A: 1, area: 1, AREA: 1, link: 1, LINK: 1 }),
|
||||
|
||||
ATTR_BOOLEAN = global.Object({
|
||||
checked: 1, disabled: 1, ismap: 1,
|
||||
multiple: 1, readonly: 1, selected: 1
|
||||
}),
|
||||
|
||||
ATTR_DEFAULT = global.Object({
|
||||
value: 'defaultValue',
|
||||
checked: 'defaultChecked',
|
||||
selected: 'defaultSelected'
|
||||
}),
|
||||
|
||||
ATTR_URIDATA = global.Object({
|
||||
action: 2, cite: 2, codebase: 2, data: 2, href: 2,
|
||||
longdesc: 2, lowsrc: 2, src: 2, usemap: 2
|
||||
}),
|
||||
|
||||
Selectors = global.Object({
|
||||
}),
|
||||
|
||||
Operators = global.Object({
|
||||
'=': "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'"
|
||||
}),
|
||||
|
||||
Optimize = global.Object({
|
||||
ID: global.RegExp('^\\*?#(' + encoding + '+)|' + skipgroup),
|
||||
TAG: global.RegExp('^(' + encoding + '+)|' + skipgroup),
|
||||
CLASS: global.RegExp('^\\*?\\.(' + encoding + '+$)|' + skipgroup)
|
||||
}),
|
||||
|
||||
Patterns = global.Object({
|
||||
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,
|
||||
dpseudos: /^\:(link|visited|target|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(([^()]*|.*)\))?(.*)/i,
|
||||
attribute: global.RegExp('^\\[' + attrmatcher + '\\](.*)'),
|
||||
children: /^\s*\>\s*(.*)/,
|
||||
adjacent: /^\s*\+\s*(.*)/,
|
||||
relative: /^\s*\~\s*(.*)/,
|
||||
ancestor: /^\s+(.*)/,
|
||||
universal: /^\*(.*)/,
|
||||
id: global.RegExp('^#(' + encoding + '+)(.*)'),
|
||||
tagName: global.RegExp('^(' + encoding + '+)(.*)'),
|
||||
className: global.RegExp('^\\.(' + encoding + '+)(.*)')
|
||||
}),
|
||||
|
||||
concatCall =
|
||||
function(data, elements, callback) {
|
||||
var i = -1, element;
|
||||
while ((element = elements[++i])) {
|
||||
if (false === callback(data[data.length] = element)) { break; }
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
switchContext =
|
||||
function(from, force) {
|
||||
var oldDoc = doc;
|
||||
lastContext = from;
|
||||
doc = from.ownerDocument || from;
|
||||
if (force || oldDoc !== doc) {
|
||||
root = doc.documentElement;
|
||||
XML_DOCUMENT = doc.createElement('DiV').nodeName == 'DiV';
|
||||
QUIRKS_MODE = !XML_DOCUMENT &&
|
||||
typeof doc.compatMode == 'string' ?
|
||||
doc.compatMode.indexOf('CSS') < 0 :
|
||||
(function() {
|
||||
var style = doc.createElement('div').style;
|
||||
return style && (style.width = 1) && style.width == '1px';
|
||||
})();
|
||||
|
||||
Config.CACHING && Dom.setCache(true, doc);
|
||||
}
|
||||
},
|
||||
|
||||
convertEscapes =
|
||||
function(str) {
|
||||
return str.replace(/\\([0-9a-fA-F]{1,6}\x20?|.)|([\x22\x27])/g, function(substring, p1, p2) {
|
||||
var codePoint, highHex, highSurrogate, lowHex, lowSurrogate;
|
||||
|
||||
if (p2) {
|
||||
return '\\' + p2;
|
||||
}
|
||||
|
||||
if (/^[0-9a-fA-F]/.test(p1)) {
|
||||
codePoint = parseInt(p1, 16);
|
||||
|
||||
if (codePoint < 0 || codePoint > 0x10ffff) {
|
||||
return '\\ufffd';
|
||||
}
|
||||
|
||||
if (codePoint <= 0xffff) {
|
||||
lowHex = '000' + codePoint.toString(16);
|
||||
return '\\u' + lowHex.substr(lowHex.length - 4);
|
||||
}
|
||||
|
||||
codePoint -= 0x10000;
|
||||
highSurrogate = (codePoint >> 10) + 0xd800;
|
||||
lowSurrogate = (codePoint % 0x400) + 0xdc00;
|
||||
highHex = '000' + highSurrogate.toString(16);
|
||||
lowHex = '000' + lowSurrogate.toString(16);
|
||||
|
||||
return '\\u' + highHex.substr(highHex.length - 4) +
|
||||
'\\u' + lowHex.substr(lowHex.length - 4);
|
||||
}
|
||||
|
||||
if (/^[\\\x22\x27]/.test(p1)) {
|
||||
return substring;
|
||||
}
|
||||
|
||||
return p1;
|
||||
});
|
||||
},
|
||||
|
||||
byIdRaw =
|
||||
function(id, elements) {
|
||||
var i = -1, element = null;
|
||||
while ((element = elements[++i])) {
|
||||
if (element.getAttribute('id') == id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
_byId = !('fileSize' in doc) ?
|
||||
function(id, from) {
|
||||
id = id.replace(/\\([^\\]{1})/g, '$1');
|
||||
return from.getElementById && from.getElementById(id) ||
|
||||
byIdRaw(id, from.getElementsByTagName('*'));
|
||||
} :
|
||||
function(id, from) {
|
||||
var element = null;
|
||||
id = id.replace(/\\([^\\]{1})/g, '$1');
|
||||
if (XML_DOCUMENT || from.nodeType != 9) {
|
||||
return byIdRaw(id, from.getElementsByTagName('*'));
|
||||
}
|
||||
if ((element = from.getElementById(id)) &&
|
||||
element.name == id && from.getElementsByName) {
|
||||
return byIdRaw(id, from.getElementsByName(id));
|
||||
}
|
||||
return element;
|
||||
},
|
||||
|
||||
byId =
|
||||
function(id, from) {
|
||||
from || (from = doc);
|
||||
if (lastContext !== from) { switchContext(from); }
|
||||
return _byId(id, from);
|
||||
},
|
||||
|
||||
byTagRaw =
|
||||
function(tag, from) {
|
||||
var any = tag == '*', element = from, elements = global.Array(), next = element.firstChild;
|
||||
any || (tag = tag.toUpperCase());
|
||||
while ((element = next)) {
|
||||
if (element.tagName > '@' && (any || element.tagName.toUpperCase() == tag)) {
|
||||
elements[elements.length] = element;
|
||||
}
|
||||
if ((next = element.firstChild || element.nextSibling)) continue;
|
||||
while (!next && (element = element.parentNode) && element !== from) {
|
||||
next = element.nextSibling;
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
},
|
||||
|
||||
contains = 'compareDocumentPosition' in root ?
|
||||
function(container, element) {
|
||||
return (container.compareDocumentPosition(element) & 16) == 16;
|
||||
} : 'contains' in root ?
|
||||
function(container, element) {
|
||||
return element.nodeType == 1 && container.contains(element);
|
||||
} :
|
||||
function(container, element) {
|
||||
while ((element = element.parentNode) && element.nodeType == 1) {
|
||||
if (element === container) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
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) :
|
||||
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) {
|
||||
var obj = node.getAttributeNode(attribute = attribute.toLowerCase());
|
||||
return ATTR_DEFAULT[attribute] && attribute != 'value' ?
|
||||
node[ATTR_DEFAULT[attribute]] : obj && obj.specified;
|
||||
},
|
||||
|
||||
isLink =
|
||||
function(element) {
|
||||
return element.getAttribute('href') && LINK_NODES[element.nodeName];
|
||||
},
|
||||
|
||||
isEmpty =
|
||||
function(node) {
|
||||
node = node.firstChild;
|
||||
while (node) {
|
||||
if (node.nodeType == 3 || node.nodeName > '@') return false;
|
||||
node = node.nextSibling;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
nthElement =
|
||||
function(element, last) {
|
||||
var count = 1, succ = last ? 'nextSibling' : 'previousSibling';
|
||||
while ((element = element[succ])) {
|
||||
if (element.nodeName > '@') ++count;
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
nthOfType =
|
||||
function(element, last) {
|
||||
var count = 1, succ = last ? 'nextSibling' : 'previousSibling', type = element.nodeName;
|
||||
while ((element = element[succ])) {
|
||||
if (element.nodeName == type) ++count;
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
configure =
|
||||
function(option) {
|
||||
if (typeof option == 'string') { return Config[option] || Config; }
|
||||
if (typeof option != 'object') { return false; }
|
||||
for (var i in option) {
|
||||
Config[i] = !!option[i];
|
||||
if (i == 'SIMPLENOT') {
|
||||
matchContexts = global.Object();
|
||||
matchResolvers = global.Object();
|
||||
selectContexts = global.Object();
|
||||
selectResolvers = global.Object();
|
||||
}
|
||||
}
|
||||
reValidator = global.RegExp(Config.SIMPLENOT ?
|
||||
standardValidator : extendedValidator);
|
||||
return true;
|
||||
},
|
||||
|
||||
emit =
|
||||
function(message) {
|
||||
if (Config.VERBOSITY) { throw global.Error(message); }
|
||||
if (global.console && global.console.log) {
|
||||
global.console.log(message);
|
||||
}
|
||||
},
|
||||
|
||||
Config = global.Object({
|
||||
CACHING: false,
|
||||
SIMPLENOT: true,
|
||||
UNIQUE_ID: true,
|
||||
USE_HTML5: true,
|
||||
VERBOSITY: true
|
||||
}),
|
||||
|
||||
IE_LT_9 = typeof doc.addEventListener != 'function',
|
||||
|
||||
INSENSITIVE_MAP = global.Object({
|
||||
href: 1, lang: 1, src: 1, style: 1, title: 1,
|
||||
type: 1, xmlns: 1, 'xml:lang': 1, 'xml:space': 1
|
||||
}),
|
||||
|
||||
TO_UPPER_CASE = IE_LT_9 ? '.toUpperCase()' : '',
|
||||
|
||||
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;' : '',
|
||||
|
||||
compile =
|
||||
function(selector, source, mode) {
|
||||
|
||||
var parts = typeof selector == 'string' ? selector.match(reSplitGroup) : selector;
|
||||
|
||||
typeof source == 'string' || (source = '');
|
||||
|
||||
if (parts.length == 1) {
|
||||
source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode);
|
||||
} else {
|
||||
var i = -1, seen = global.Object(), token;
|
||||
while ((token = parts[++i])) {
|
||||
token = token.replace(reTrimSpaces, '');
|
||||
if (!seen[token] && (seen[token] = true)) {
|
||||
source += compileSelector(token, mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode) {
|
||||
return global.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 global.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, mode) {
|
||||
|
||||
var a, b, n, k = 0, expr, match, name, result, status, test, type;
|
||||
|
||||
while (selector) {
|
||||
|
||||
k++;
|
||||
|
||||
if ((match = selector.match(Patterns.universal))) {
|
||||
expr = '';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.id))) {
|
||||
source = 'if(' + (XML_DOCUMENT ?
|
||||
's.getAttribute(e,"id")' :
|
||||
'(e.submit?s.getAttribute(e,"id"):e.id)') +
|
||||
'=="' + match[1] + '"' +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.tagName))) {
|
||||
source = 'if(e.nodeName' + (XML_DOCUMENT ?
|
||||
'=="' + match[1] + '"' : TO_UPPER_CASE +
|
||||
'=="' + match[1].toUpperCase() + '"') +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.className))) {
|
||||
source = 'if((n=' + (XML_DOCUMENT ?
|
||||
'e.getAttribute("class")' : 'e.className') +
|
||||
')&&n.length&&(" "+' + (QUIRKS_MODE ? 'n.toLowerCase()' : 'n') +
|
||||
'.replace(/\\s+/g," ")+" ").indexOf(" ' +
|
||||
(QUIRKS_MODE ? match[1].toLowerCase() : match[1]) + ' ")>-1' +
|
||||
'){' + source + '}';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.attribute))) {
|
||||
if (match[2] && !Operators[match[2]]) {
|
||||
emit('Unsupported operator in attribute selectors "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
test = 'false';
|
||||
if (match[2] && match[4] && (test = Operators[match[2]])) {
|
||||
match[4] = convertEscapes(match[4]);
|
||||
type = INSENSITIVE_MAP[match[1].toLowerCase()];
|
||||
test = test.replace(/\%m/g, type ? match[4].toLowerCase() : match[4]);
|
||||
} else if (match[2] == '!=' || match[2] == '=') {
|
||||
test = 'n' + match[2] + '=""';
|
||||
}
|
||||
source = 'if(n=s.hasAttribute(e,"' + match[1] + '")){' +
|
||||
(match[2] ? 'n=s.getAttribute(e,"' + match[1] + '")' : '') +
|
||||
(type && match[2] ? '.toLowerCase();' : ';') +
|
||||
'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 + ';';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.relative))) {
|
||||
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 = (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 + ';';
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.spseudos)) && match[1]) {
|
||||
switch (match[1]) {
|
||||
case 'root':
|
||||
if (match[3]) {
|
||||
source = 'if(e===h||s.contains(h,e)){' + source + '}';
|
||||
} else {
|
||||
source = 'if(e===h){' + source + '}';
|
||||
}
|
||||
break;
|
||||
case 'empty':
|
||||
source = 'if(s.isEmpty(e)){' + source + '}';
|
||||
break;
|
||||
default:
|
||||
if (match[1] && match[2]) {
|
||||
if (match[2] == 'n') {
|
||||
source = 'if(e!==h){' + source + '}';
|
||||
break;
|
||||
} else if (match[2] == 'even') {
|
||||
a = 2;
|
||||
b = 0;
|
||||
} else if (match[2] == 'odd') {
|
||||
a = 2;
|
||||
b = 1;
|
||||
} else {
|
||||
b = ((n = match[2].match(/(-?\d+)$/)) ? global.parseInt(n[1], 10) : 0);
|
||||
a = ((n = match[2].match(/(-?\d*)n/i)) ? global.parseInt(n[1], 10) : 0);
|
||||
if (n && n[1] == '-') a = -1;
|
||||
}
|
||||
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 : a == -1 ? 'n<=' + b : 'n>=' + b;
|
||||
source =
|
||||
'if(e!==h){' +
|
||||
'n=s[' + (/-of-type/i.test(match[1]) ? '"nthOfType"' : '"nthElement"') + ']' +
|
||||
'(e,' + (/last/i.test(match[1]) ? 'true' : 'false') + ');' +
|
||||
'if(' + test + '){' + source + '}' +
|
||||
'}';
|
||||
} else {
|
||||
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){' +
|
||||
( 'n=e;while((n=n.' + a + 'Sibling)' + type + ');if(!n){' + (b ? source :
|
||||
'n=e;while((n=n.' + n + 'Sibling)' + type + ');if(!n){' + source + '}') + '}' ) + '}';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else if ((match = selector.match(Patterns.dpseudos)) && match[1]) {
|
||||
switch (match[1].match(/^\w+/)[0]) {
|
||||
case 'not':
|
||||
expr = match[3].replace(reTrimSpaces, '');
|
||||
if (Config.SIMPLENOT && !reSimpleNot.test(expr)) {
|
||||
emit('Negation pseudo-class only accepts simple selectors "' + match.join('') + '"');
|
||||
return '';
|
||||
} else {
|
||||
if ('compatMode' in doc) {
|
||||
source = 'if(!' + compile(expr, '', false) + '(e,s,r,d,h,g)){' + source + '}';
|
||||
} else {
|
||||
source = 'if(!s.match(e, "' + expr.replace(/\x22/g, '\\"') + '",g)){' + source +'}';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'checked':
|
||||
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"' +
|
||||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') +
|
||||
')||s.isLink(e))&&e.disabled===true){' + source + '}';
|
||||
break;
|
||||
case 'enabled':
|
||||
source = 'if(((typeof e.form!=="undefined"' +
|
||||
(Config.USE_HTML5 ? '' : '&&!(/^hidden$/i).test(e.type)') +
|
||||
')||s.isLink(e))&&e.disabled===false){' + source + '}';
|
||||
break;
|
||||
case 'lang':
|
||||
test = '';
|
||||
if (match[2]) test = match[2].substr(0, 2) + '-';
|
||||
source = 'do{(n=e.lang||"").toLowerCase();' +
|
||||
'if((n==""&&h.lang=="' + match[2].toLowerCase() + '")||' +
|
||||
'(n&&(n=="' + match[2].toLowerCase() +
|
||||
'"||n.substr(0,3)=="' + test.toLowerCase() + '")))' +
|
||||
'{' + source + 'break;}}while((e=e.parentNode)&&e!==g);';
|
||||
break;
|
||||
case 'target':
|
||||
source = 'if(e.id==d.location.hash.slice(1)){' + source + '}';
|
||||
break;
|
||||
case 'link':
|
||||
source = 'if(s.isLink(e)&&!e.visited){' + source + '}';
|
||||
break;
|
||||
case 'visited':
|
||||
source = 'if(s.isLink(e)&&e.visited){' + source + '}';
|
||||
break;
|
||||
case 'active':
|
||||
source = 'if(e===d.activeElement){' + source + '}';
|
||||
break;
|
||||
case 'hover':
|
||||
source = 'if(e===d.hoverElement){' + source + '}';
|
||||
break;
|
||||
case 'focus':
|
||||
source = 'hasFocus' in doc ?
|
||||
'if(e===d.activeElement&&d.hasFocus()&&(e.type||e.href||typeof e.tabIndex=="number")){' + source + '}' :
|
||||
'if(e===d.activeElement&&(e.type||e.href)){' + source + '}';
|
||||
break;
|
||||
case 'selected':
|
||||
source = 'if(/^option$/i.test(e.nodeName)&&(e.selected||e.checked)){' + source + '}';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
expr = false;
|
||||
status = false;
|
||||
for (expr in Selectors) {
|
||||
if ((match = selector.match(Selectors[expr].Expression)) && match[1]) {
|
||||
result = Selectors[expr].Callback(match, source);
|
||||
source = result.source;
|
||||
status = result.status;
|
||||
if (status) { break; }
|
||||
}
|
||||
}
|
||||
|
||||
if (!status) {
|
||||
emit('Unknown pseudo-class selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
if (!expr) {
|
||||
emit('Unknown token in selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
emit('Invalid syntax in selector "' + selector + '"');
|
||||
return '';
|
||||
}
|
||||
|
||||
selector = match && match[match.length - 1];
|
||||
}
|
||||
|
||||
return source;
|
||||
},
|
||||
|
||||
match =
|
||||
function(element, selector, from, callback) {
|
||||
|
||||
var parts;
|
||||
|
||||
if (!(element && element.nodeType == 1)) {
|
||||
emit('Invalid element argument');
|
||||
return false;
|
||||
} else if (typeof selector != 'string') {
|
||||
emit('Invalid selector argument');
|
||||
return false;
|
||||
} else if (lastContext !== from) {
|
||||
switchContext(from || (from = element.ownerDocument));
|
||||
}
|
||||
|
||||
selector = selector.replace(reTrimSpaces, '');
|
||||
|
||||
Config.SHORTCUTS && (selector = Dom.shortcuts(selector, element, from));
|
||||
|
||||
if (lastMatcher != selector) {
|
||||
if ((parts = selector.match(reValidator)) && parts[0] == selector) {
|
||||
isSingleMatch = (parts = selector.match(reSplitGroup)).length < 2;
|
||||
lastMatcher = selector;
|
||||
lastPartsMatch = parts;
|
||||
} else {
|
||||
emit('The string "' + selector + '", is not a valid CSS selector');
|
||||
return false;
|
||||
}
|
||||
} else parts = lastPartsMatch;
|
||||
|
||||
if (!matchResolvers[selector] || matchContexts[selector] !== from) {
|
||||
matchResolvers[selector] = compile(isSingleMatch ? [selector] : parts, '', false);
|
||||
matchContexts[selector] = from;
|
||||
}
|
||||
|
||||
return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, { });
|
||||
},
|
||||
|
||||
first =
|
||||
function(selector, from) {
|
||||
return select(selector, from, function() { return false; })[0] || null;
|
||||
},
|
||||
|
||||
select =
|
||||
function(selector, from, callback) {
|
||||
|
||||
var i, changed, element, elements, parts, token, original = selector;
|
||||
|
||||
if (arguments.length === 0) {
|
||||
emit('Not enough arguments');
|
||||
return [ ];
|
||||
} else if (typeof selector != 'string') {
|
||||
return [ ];
|
||||
} else if (from && !(/1|9|11/).test(from.nodeType)) {
|
||||
emit('Invalid or illegal context element');
|
||||
return [ ];
|
||||
} else if (lastContext !== from) {
|
||||
switchContext(from || (from = doc));
|
||||
}
|
||||
|
||||
if (Config.CACHING && (elements = Dom.loadResults(original, from, doc, root))) {
|
||||
return callback ? concatCall([ ], elements, callback) : elements;
|
||||
}
|
||||
|
||||
selector = selector.replace(reTrimSpaces, '');
|
||||
|
||||
Config.SHORTCUTS && (selector = Dom.shortcuts(selector, from));
|
||||
|
||||
if ((changed = lastSelector != selector)) {
|
||||
if ((parts = selector.match(reValidator)) && parts[0] == selector) {
|
||||
isSingleSelect = (parts = selector.match(reSplitGroup)).length < 2;
|
||||
lastSelector = selector;
|
||||
lastPartsSelect = parts;
|
||||
} else {
|
||||
emit('The string "' + selector + '", is not a valid CSS selector');
|
||||
return [ ];
|
||||
}
|
||||
} else parts = lastPartsSelect;
|
||||
|
||||
if (from.nodeType == 11) {
|
||||
|
||||
elements = byTagRaw('*', from);
|
||||
|
||||
} else if (isSingleSelect) {
|
||||
|
||||
if (changed) {
|
||||
parts = selector.match(reSplitToken);
|
||||
token = parts[parts.length - 1];
|
||||
lastSlice = token.split(':not')[0];
|
||||
lastPosition = selector.length - token.length;
|
||||
}
|
||||
|
||||
if (Config.UNIQUE_ID && (parts = lastSlice.match(Optimize.ID)) && (token = parts[1])) {
|
||||
if ((element = _byId(token, from))) {
|
||||
if (match(element, selector)) {
|
||||
callback && callback(element);
|
||||
elements = global.Array(element);
|
||||
} else elements = global.Array();
|
||||
}
|
||||
}
|
||||
|
||||
else if (Config.UNIQUE_ID && (parts = selector.match(Optimize.ID)) && (token = parts[1])) {
|
||||
if ((element = _byId(token, doc))) {
|
||||
if ('#' + token == selector) {
|
||||
callback && callback(element);
|
||||
elements = global.Array(element);
|
||||
} else if (/[>+~]/.test(selector)) {
|
||||
from = element.parentNode;
|
||||
} else {
|
||||
from = element;
|
||||
}
|
||||
} else elements = global.Array();
|
||||
}
|
||||
|
||||
if (elements) {
|
||||
Config.CACHING && Dom.saveResults(original, from, doc, elements);
|
||||
return elements;
|
||||
}
|
||||
|
||||
if (!XML_DOCUMENT && GEBTN && (parts = lastSlice.match(Optimize.TAG)) && (token = parts[1])) {
|
||||
if ((elements = from.getElementsByTagName(token)).length === 0) { return [ ]; }
|
||||
selector = selector.slice(0, lastPosition) + selector.slice(lastPosition).replace(token, '*');
|
||||
}
|
||||
|
||||
else if (!XML_DOCUMENT && GEBCN && (parts = lastSlice.match(Optimize.CLASS)) && (token = parts[1])) {
|
||||
if ((elements = from.getElementsByClassName(token.replace(/\\([^\\]{1})/g, '$1'))).length === 0) { return [ ]; }
|
||||
selector = selector.slice(0, lastPosition) + selector.slice(lastPosition).replace('.' + token,
|
||||
reOptimizeSelector.test(selector.charAt(selector.indexOf(token) - 1)) ? '' : '*');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!elements) {
|
||||
if (IE_LT_9) {
|
||||
elements = /^(?:applet|object)$/i.test(from.nodeName) ? from.childNodes : from.all;
|
||||
} else {
|
||||
elements = from.getElementsByTagName('*');
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectResolvers[selector] || selectContexts[selector] !== from) {
|
||||
selectResolvers[selector] = compile(isSingleSelect ? [selector] : parts, REJECT_NODE, true);
|
||||
selectContexts[selector] = from;
|
||||
}
|
||||
|
||||
elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, { });
|
||||
|
||||
Config.CACHING && Dom.saveResults(original, from, doc, elements);
|
||||
|
||||
return elements;
|
||||
},
|
||||
|
||||
FN = function(x) { return x; },
|
||||
|
||||
matchContexts = global.Object(),
|
||||
matchResolvers = global.Object(),
|
||||
|
||||
selectContexts = global.Object(),
|
||||
selectResolvers = global.Object(),
|
||||
|
||||
Snapshot = global.Object({
|
||||
byId: _byId,
|
||||
match: match,
|
||||
select: select,
|
||||
isLink: isLink,
|
||||
isEmpty: isEmpty,
|
||||
contains: contains,
|
||||
nthOfType: nthOfType,
|
||||
nthElement: nthElement,
|
||||
getAttribute: getAttribute,
|
||||
hasAttribute: hasAttribute
|
||||
});
|
||||
|
||||
Dom.ACCEPT_NODE = ACCEPT_NODE;
|
||||
|
||||
Dom.byId = byId;
|
||||
Dom.match = match;
|
||||
Dom.first = first;
|
||||
Dom.select = select;
|
||||
Dom.compile = compile;
|
||||
Dom.contains = contains;
|
||||
Dom.configure = configure;
|
||||
Dom.getAttribute = getAttribute;
|
||||
Dom.hasAttribute = hasAttribute;
|
||||
|
||||
Dom.setCache = FN;
|
||||
Dom.shortcuts = FN;
|
||||
Dom.loadResults = FN;
|
||||
Dom.saveResults = FN;
|
||||
|
||||
Dom.emit = emit;
|
||||
Dom.Config = Config;
|
||||
Dom.Snapshot = Snapshot;
|
||||
|
||||
Dom.Operators = Operators;
|
||||
Dom.Selectors = Selectors;
|
||||
|
||||
Dom.Version = version;
|
||||
|
||||
Dom.registerOperator =
|
||||
function(symbol, resolver) {
|
||||
Operators[symbol] || (Operators[symbol] = resolver);
|
||||
};
|
||||
|
||||
Dom.registerSelector =
|
||||
function(name, rexp, func) {
|
||||
Selectors[name] || (Selectors[name] = global.Object({
|
||||
Expression: rexp,
|
||||
Callback: func
|
||||
}));
|
||||
};
|
||||
|
||||
switchContext(doc, true);
|
||||
|
||||
});
|
||||
1725
node_modules/nwmatcher/src/nwmatcher.js
generated
vendored
Normal file
1725
node_modules/nwmatcher/src/nwmatcher.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user