nwmatcher
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "nwmatcher", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A CSS3-compliant JavaScript selector engine.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://javascript.nwbox.com/NWMatcher/", |
@@ -5,6 +5,14 @@ # NWMatcher | ||
## Install | ||
To include NWMatcher in a standard web page: | ||
<script type="text/javascript" src="nwmatcher.js"></script> | ||
In nodeJS: | ||
$ npm install nwmatcher.js | ||
## Notes | ||
@@ -14,1 +22,72 @@ | ||
# Supported selectors | ||
Here is a list of all the CSS2/CSS3 [Supported selectors](https://github.com/dperini/nwmatcher/wiki/CSS-supported-selectors). | ||
# Features and compliance | ||
You can read more about NWMatcher [Features and compliance](https://github.com/dperini/nwmatcher/wiki/Features-and-compliance). | ||
# DOM Selection API | ||
*first( selector, context )* | ||
>return a reference to the first element matching the selector starting at context | ||
*match( element, selector, context )* | ||
>return true if the element matches the selector, return false otherwise, starting at context | ||
*select( selector, context, callback )* | ||
>return an array of all the elements matching the selector starting at context, if available invoke the callback for each element | ||
# DOM Helpers API | ||
*byId( id, from )* | ||
>return a reference to the first element matching the ID | ||
*byTag( tag, from )* | ||
>return an array of element having the specified tag name | ||
*byClass( class, from )* | ||
>return an array of element having the specified class name | ||
*byName( name, from )* | ||
>return an array of element having the specified name attribute | ||
*getAttribute( element, attribute )* | ||
>return the value read from the element attribute as a string | ||
*hasAttribute( element, attribute )* | ||
>return true if the element has the attribute set, return false otherwise | ||
# Engine Configuration | ||
*configure( options )* | ||
>the following 'flags' exists and can be set to true/false: | ||
* CACHING: enable/disable caching of results | ||
* SHORTCUTS: allow accepting mangled selectors | ||
* SIMPLENOT: allow nested complex :not() selectors | ||
* UNIQUE_ID: allow multiple elements with same ID | ||
* USE_QSAPI: enable native querySelectorAll if available | ||
* USE_HTML5: enable/disable special HTML5 rules (checked/selected) | ||
* VERBOSITY: enable/disable throwing of errors or just console warnings | ||
>Example: configure( { USE_QSAPI: false, VERBOSITY: false } ); | ||
*registerOperator( symbol, resolver )* | ||
>register a new symbol and its matching resolver in the Operators table | ||
>Example: NW.Dom.registerOperator( '!=', 'n!="%m"' ); | ||
*registerSelector( name, rexp, func )* | ||
>register a new selector, the matching RegExp and the appropriate resolver function in the Selectors table | ||
/* | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* Copyright (C) 2007-2013 Diego Perini | ||
* All rights reserved. | ||
@@ -4,0 +4,0 @@ * |
@@ -89,4 +89,4 @@ /* | ||
case 'text': | ||
// :checkbox, :file, :image, :password, :radio, :reset, :submit, :text ... | ||
source = 'if(e.type&&e.getAttribute("type")=="' + match[1] + '"){' + source + '}'; | ||
// :checkbox, :file, :image, :password, :radio, :reset, :submit, :text | ||
source = 'if(/^' + match[1] + '$/i.test(e.type)){' + source + '}'; | ||
break; | ||
@@ -93,0 +93,0 @@ case 'button': |
/* | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* Copyright (C) 2007-2013 Diego Perini | ||
* All rights reserved. | ||
@@ -4,0 +4,0 @@ * |
/* | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* Copyright (C) 2007-2013 Diego Perini | ||
* All rights reserved. | ||
@@ -8,5 +8,5 @@ * | ||
* Author: Diego Perini <diego.perini at gmail com> | ||
* Version: 1.3.0 | ||
* Version: 1.3.1 | ||
* Created: 20070722 | ||
* Release: 20130110 | ||
* Release: 20130211 | ||
* | ||
@@ -39,3 +39,3 @@ * License: | ||
var version = 'nwmatcher-1.3.0', | ||
var version = 'nwmatcher-1.3.1', | ||
@@ -119,3 +119,3 @@ Dom = exports, | ||
'\\(' + pseudoclass + '\\)|' + | ||
'[^\\x20\\t\\n\\r\\f>+~]|\\\\.)+', 'g'), | ||
'\\\\.|[^\\x20\\t\\n\\r\\f>+~])+', 'g'), | ||
@@ -473,3 +473,3 @@ reWhiteSpace = /[\x20\t\n\r\f]+/g, | ||
return false; | ||
} else if (!selector || typeof selector != 'string') { | ||
} else if (typeof selector != 'string') { | ||
emit('Invalid selector argument'); | ||
@@ -519,5 +519,2 @@ return false; | ||
return [ ]; | ||
} else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) { | ||
emit('Invalid or illegal selector string'); | ||
return [ ]; | ||
} else if (from && !(/1|9|11/).test(from.nodeType)) { | ||
@@ -524,0 +521,0 @@ emit('Invalid or illegal context element'); |
/* | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* Copyright (C) 2007-2013 Diego Perini | ||
* All rights reserved. | ||
@@ -8,5 +8,5 @@ * | ||
* Author: Diego Perini <diego.perini at gmail com> | ||
* Version: 1.3.0 | ||
* Version: 1.3.1 | ||
* Created: 20070722 | ||
* Release: 20130110 | ||
* Release: 20130211 | ||
* | ||
@@ -108,3 +108,3 @@ * License: | ||
'\\(' + pseudoclass + '\\)|' + | ||
'[^\\s>+~]|\\\\.)+', 'g'), | ||
'\\\\.|[^\\s>+~])+', 'g'), | ||
@@ -638,3 +638,3 @@ reOptimizeSelector = RegExp(identifier + '|^$'), | ||
return false; | ||
} else if (!selector || typeof selector != 'string') { | ||
} else if (typeof selector != 'string') { | ||
emit('Invalid selector argument'); | ||
@@ -684,5 +684,2 @@ return false; | ||
return [ ]; | ||
} else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) { | ||
emit('Invalid or illegal selector string'); | ||
return [ ]; | ||
} else if (from && !(/1|9|11/).test(from.nodeType)) { | ||
@@ -689,0 +686,0 @@ emit('Invalid or illegal context element'); |
/* | ||
* Copyright (C) 2007-2012 Diego Perini | ||
* Copyright (C) 2007-2013 Diego Perini | ||
* All rights reserved. | ||
@@ -8,5 +8,5 @@ * | ||
* Author: Diego Perini <diego.perini at gmail com> | ||
* Version: 1.3.0 | ||
* Version: 1.3.1 | ||
* Created: 20070722 | ||
* Release: 20130110 | ||
* Release: 20130211 | ||
* | ||
@@ -21,3 +21,3 @@ * License: | ||
if (typeof module === 'object' && typeof exports === 'object') { | ||
if (typeof module == 'object' && typeof exports == 'object') { | ||
// in a Node.js environment, the nwmatcher functions will operate on | ||
@@ -44,3 +44,3 @@ // the passed "browserGlobal" and will be returned in an object | ||
var version = 'nwmatcher-1.3.0', | ||
var version = 'nwmatcher-1.3.1', | ||
@@ -191,3 +191,3 @@ Dom = exports, | ||
'\\(' + pseudoclass + '\\)|' + | ||
'[^\\x20\\t\\r\\n\\f>+~]|\\\\.)+', 'g'), | ||
'\\\\.|[^\\x20\\t\\r\\n\\f>+~])+', 'g'), | ||
@@ -1293,3 +1293,3 @@ // for in excess whitespace removal | ||
return false; | ||
} else if (!selector || typeof selector != 'string') { | ||
} else if (typeof selector != 'string') { | ||
emit('Invalid selector argument'); | ||
@@ -1322,3 +1322,3 @@ return false; | ||
// compile matcher resolver if necessary | ||
// compile matcher resolvers if necessary | ||
if (!matchResolvers[selector] || matchContexts[selector] !== from) { | ||
@@ -1353,5 +1353,2 @@ matchResolvers[selector] = compile(isSingleMatch ? [selector] : parts, '', false); | ||
return [ ]; | ||
} else if (!(/[>+~*\w\u00a1-\uffff]/.test(selector))) { | ||
emit('Invalid or illegal selector string'); | ||
return [ ]; | ||
} else if (from && !(/1|9|11/).test(from.nodeType)) { | ||
@@ -1373,5 +1370,7 @@ emit('Invalid or illegal context element'); | ||
case '#': | ||
if (Config.UNIQUE_ID && (element = _byId(selector.slice(1), from))) { | ||
elements = [ element ]; | ||
} else elements = [ ]; | ||
if (Config.UNIQUE_ID) { | ||
if (element = _byId(selector.slice(1), from)) { | ||
elements = [ element ]; | ||
} else elements = [ ]; | ||
} | ||
break; | ||
@@ -1378,0 +1377,0 @@ case '.': |
Sorry, the diff of this file is not supported yet
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
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
1
138105
17
3489