diff --git a/bower.json b/bower.json index 8855443..3647475 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nwmatcher", - "version": "1.3.9beta", + "version": "1.3.9", "homepage": "https://github.com/dperini/nwmatcher", "authors": [ "Diego Perini " diff --git a/build/HEADER b/build/HEADER index d47da6e..a6eba15 100644 --- a/build/HEADER +++ b/build/HEADER @@ -1,5 +1,5 @@ /*! - * NWMatcher 1.3.9beta - Fast CSS3 Selector Engine + * NWMatcher 1.3.9 - Fast CSS3 Selector Engine * Copyright (C) 2007-2016 Diego Perini * See http://nwbox.com/license */ diff --git a/build/VERSION b/build/VERSION index a72a4cf..d4c4950 100644 --- a/build/VERSION +++ b/build/VERSION @@ -1 +1 @@ -1.3.9beta +1.3.9 diff --git a/package.json b/package.json index 6f7f45c..1e7bbea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nwmatcher", - "version": "1.3.9beta", + "version": "1.3.9", "description": "A CSS3-compliant JavaScript selector engine.", "homepage": "http://javascript.nwbox.com/NWMatcher/", "main": "./src/nwmatcher", diff --git a/src/nwmatcher-base.js b/src/nwmatcher-base.js index 93cc1c8..35a7926 100644 --- a/src/nwmatcher-base.js +++ b/src/nwmatcher-base.js @@ -5,9 +5,9 @@ * nwmatcher-base.js - A fast CSS selector engine and matcher * * Author: Diego Perini - * Version: 1.3.9beta + * Version: 1.3.9 * Created: 20070722 - * Release: 20161013 + * Release: 20161026 * * License: * http://javascript.nwbox.com/NWMatcher/MIT-LICENSE @@ -28,7 +28,7 @@ })(this, function(global) { - var version = 'nwmatcher-1.3.9beta', + var version = 'nwmatcher-1.3.9', doc = global.document, root = doc.documentElement, diff --git a/src/nwmatcher-noqsa.js b/src/nwmatcher-noqsa.js index 9ecf812..8ecc0ce 100644 --- a/src/nwmatcher-noqsa.js +++ b/src/nwmatcher-noqsa.js @@ -5,9 +5,9 @@ * nwmatcher-noqsa.js - A fast CSS selector engine and matcher * * Author: Diego Perini - * Version: 1.3.9beta + * Version: 1.3.9 * Created: 20070722 - * Release: 20161013 + * Release: 20161026 * * License: * http://javascript.nwbox.com/NWMatcher/MIT-LICENSE @@ -28,7 +28,7 @@ })(this, function(global) { - var version = 'nwmatcher-1.3.9beta', + var version = 'nwmatcher-1.3.9', doc = global.document, root = doc.documentElement, diff --git a/src/nwmatcher.js b/src/nwmatcher.js index de8973c..9befeea 100644 --- a/src/nwmatcher.js +++ b/src/nwmatcher.js @@ -5,9 +5,9 @@ * nwmatcher.js - A fast CSS selector engine and matcher * * Author: Diego Perini - * Version: 1.3.9beta + * Version: 1.3.9 * Created: 20070722 - * Release: 20161013 + * Release: 20161026 * * License: * http://javascript.nwbox.com/NWMatcher/MIT-LICENSE @@ -28,7 +28,7 @@ })(this, function(global) { - var version = 'nwmatcher-1.3.9beta', + var version = 'nwmatcher-1.3.9', // processing context & root element doc = global.document, diff --git a/test/css3-compat/css3-compat.js b/test/css3-compat/css3-compat.js index 82dc3e7..3c315c1 100644 --- a/test/css3-compat/css3-compat.js +++ b/test/css3-compat/css3-compat.js @@ -13,7 +13,7 @@ var CDN = 'http://ajax.googleapis.com/ajax/libs/', engines = { 'querySelectorAll': [ 'document.querySelectorAll(s)', '' ], - 'nwmatcher-1.3.9beta': [ 'NW.Dom.select(s)', '../../src/nwmatcher.js' ] + 'nwmatcher-1.3.9': [ 'NW.Dom.select(s)', '../../src/nwmatcher.js' ] // 'base2-2.0alpha1': [ 'base2.dom.querySelectorAll(c,s)', 'lib/base2+dom.js' ], // 'prototype-1.6.1': [ '$$(s)', CDN + 'prototype/1.6.1.0/prototype.js' ], diff --git a/test/ender/ender.js b/test/ender/ender.js index 203027d..e3480a1 100644 --- a/test/ender/ender.js +++ b/test/ender/ender.js @@ -101,9 +101,9 @@ * nwmatcher.js - A fast CSS selector engine and matcher * * Author: Diego Perini - * Version: 1.3.9beta + * Version: 1.3.9 * Created: 20070722 - * Release: 20161013 + * Release: 20161026 * * License: * http://javascript.nwbox.com/NWMatcher/MIT-LICENSE @@ -114,50 +114,24 @@ (function(global, factory) { 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) { - // 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; + module.exports = factory; + } else if (typeof define === 'function' && define["amd"]) { + define(factory); } else { - // in a browser environment, the nwmatcher functions will operate on - // the "global" loading them and be attached to "global.NW.Dom" - factory(global, - (global.NW || (global.NW = global.Object())) && - (global.NW.Dom || (global.NW.Dom = global.Object()))); - global.NW.Dom.factory = factory; + global.NW || (global.NW = { }); + global.NW.Dom = factory(global); } - })(this, function(global, exports) { - - var version = 'nwmatcher-1.3.9beta', + })(this, function(global) { - Dom = exports, + var version = 'nwmatcher-1.3.9', // processing context & root element doc = global.document, root = doc.documentElement, // save utility methods references - slice = global.Array.prototype.slice, - string = global.Object.prototype.toString, + slice = [ ].slice, // persist previous parsed data isSingleMatch, @@ -213,7 +187,7 @@ // regular expression to trim extra leading/trailing whitespace in selector strings // whitespace is any combination of these 5 character [\x20\t\n\r\f] // http://www.w3.org/TR/css3-selectors/#selector-syntax - reTrimSpaces = global.RegExp('[\\n\\r\\f]|^' + whitespace + '+|' + whitespace + '+$', 'g'), + reTrimSpaces = RegExp('[\\n\\r\\f]|^' + whitespace + '+|' + whitespace + '+$', 'g'), // regular expression used in convertEscapes and unescapeIdentifier reEscapedChars = /\\([0-9a-fA-F]{1,6}[\x20\t\n\r\f]?|.)|([\x22\x27])/g, @@ -241,35 +215,35 @@ extensions = '.+', // precompiled Regular Expressions - Patterns = new global.Object({ + Patterns = { // structural pseudo-classes and child selectors 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|active|focus|hover|checked|disabled|enabled|selected|lang\(([-\w]{2,})\)|not\(\s*(:nth(?:-last)?(?:-child|-of-type)\(\s*(?:even|odd|(?:[-+]{0,1}\d*n\s*)?[-+]{0,1}\s*\d*)\s*\)|[^()]*)\s*\))?(.*)/i, // E > F - children: new global.RegExp('^' + whitespace + '*\\>' + whitespace + '*(.*)'), + children: RegExp('^' + whitespace + '*\\>' + whitespace + '*(.*)'), // E + F - adjacent: new global.RegExp('^' + whitespace + '*\\+' + whitespace + '*(.*)'), + adjacent: RegExp('^' + whitespace + '*\\+' + whitespace + '*(.*)'), // E ~ F - relative: new global.RegExp('^' + whitespace + '*\\~' + whitespace + '*(.*)'), + relative: RegExp('^' + whitespace + '*\\~' + whitespace + '*(.*)'), // E F - ancestor: new global.RegExp('^' + whitespace + '+(.*)'), + ancestor: RegExp('^' + whitespace + '+(.*)'), // all - universal: new global.RegExp('^\\*(.*)') - }), + universal: RegExp('^\\*(.*)') + }, - Tokens = global.Object({ + Tokens = { prefixes: prefixes, identifier: identifier, attributes: attributes - }), + }, /*----------------------------- FEATURE TESTING ----------------------------*/ // detect native methods isNative = (function() { var re = / \w+\(/, - isnative = String(Object.prototype.toString).replace(re, ' ('); + isnative = String(({ }).toString).replace(re, ' ('); return function(method) { return method && typeof method != 'string' && isnative == String(method).replace(re, ' ('); @@ -310,7 +284,7 @@ // detect buggy gEBID BUGGY_GEBID = NATIVE_GEBID ? (function() { - var isBuggy = true, x = 'x' + global.String(+new global.Date), + var isBuggy = true, x = 'x' + String(+new Date), a = doc.createElementNS ? 'a' : ''; (a = doc.createElement(a)).name = x; root.insertBefore(a, root.firstChild); @@ -385,15 +359,16 @@ XML_DOCUMENT, // detect Opera browser - OPERA = /opera/i.test(string.call(global.opera)), + OPERA = typeof global.opera != 'undefined' && + (/opera/i).test(({ }).toString.call(global.opera)), // skip simple selector optimizations for Opera >= 11 - OPERA_QSAPI = OPERA && global.parseFloat(global.opera.version()) >= 11, + OPERA_QSAPI = OPERA && parseFloat(global.opera.version()) >= 11, // check Selector API implementations RE_BUGGY_QSAPI = NATIVE_QSAPI ? (function() { - var pattern = new global.Array(), context, element, + var pattern = [ ], context, element, expect = function(selector, element, n) { var result = false; @@ -461,7 +436,7 @@ } return pattern.length ? - new global.RegExp(pattern.join('|')) : + RegExp(pattern.join('|')) : { 'test': function() { return false; } }; })() : @@ -471,30 +446,30 @@ IE_LT_9 = typeof doc.addEventListener != 'function', - LINK_NODES = new global.Object({ 'a': 1, 'A': 1, 'area': 1, 'AREA': 1, 'link': 1, 'LINK': 1 }), + LINK_NODES = { 'a': 1, 'A': 1, 'area': 1, 'AREA': 1, 'link': 1, 'LINK': 1 }, // boolean attributes should return attribute name instead of true/false - ATTR_BOOLEAN = new global.Object({ + ATTR_BOOLEAN = { 'checked': 1, 'disabled': 1, 'ismap': 1, 'multiple': 1, 'readonly': 1, 'selected': 1 - }), + }, // dynamic attributes that needs to be checked against original HTML value - ATTR_DEFAULT = new global.Object({ + ATTR_DEFAULT = { 'value': 'defaultValue', 'checked': 'defaultChecked', 'selected': 'defaultSelected' - }), + }, // attributes referencing URI data values need special treatment in IE - ATTR_URIDATA = new global.Object({ + ATTR_URIDATA = { 'action': 2, 'cite': 2, 'codebase': 2, 'data': 2, 'href': 2, 'longdesc': 2, 'lowsrc': 2, 'src': 2, 'usemap': 2 - }), + }, // HTML 5 draft specifications // http://www.whatwg.org/specs/web-apps/current-work/#selectors - HTML_TABLE = new global.Object({ + HTML_TABLE = { // class attribute must be treated case-insensitive in HTML quirks mode // initialized by default to Standard Mode (case-sensitive), // set dynamically by the attribute resolver @@ -507,22 +482,22 @@ 'noresize': 1, 'noshade': 1, 'nowrap': 1, 'readonly': 1, 'rel': 1, 'rev': 1, 'rules': 1, 'scope': 1, 'scrolling': 1, 'selected': 1, 'shape': 1, 'target': 1, 'text': 1, 'type': 1, 'valign': 1, 'valuetype': 1, 'vlink': 1 - }), + }, // the following attributes must be treated case-insensitive in XHTML mode // Niels Leenheer http://rakaz.nl/item/css_selector_bugs_case_sensitivity - XHTML_TABLE = new global.Object({ + XHTML_TABLE = { 'accept': 1, 'accept-charset': 1, 'alink': 1, 'axis': 1, 'bgcolor': 1, 'charset': 1, 'codetype': 1, 'color': 1, 'enctype': 1, 'face': 1, 'hreflang': 1, 'http-equiv': 1, 'lang': 1, 'language': 1, 'link': 1, 'media': 1, 'rel': 1, 'rev': 1, 'target': 1, 'text': 1, 'type': 1, 'vlink': 1 - }), + }, /*-------------------------- REGULAR EXPRESSIONS ---------------------------*/ // placeholder to add functionalities - Selectors = new global.Object({ + Selectors = { // as a simple example this will check // for chars not in standard ascii table // @@ -534,17 +509,17 @@ // 'mySelectorCallback' will be invoked // only after passing all other standard // checks and only if none of them worked - }), + }, // attribute operators - Operators = new global.Object({ + Operators = { '=': "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'" - }), + }, /*------------------------------ UTIL METHODS ------------------------------*/ @@ -552,8 +527,8 @@ concatList = function(data, elements) { var i = -1, element; - if (!data.length && global.Array.slice) - return global.Array.slice(elements); + if (!data.length && Array.slice) + return Array.slice(elements); while ((element = elements[++i])) data[data.length] = element; return data; @@ -743,7 +718,7 @@ // @return array byTagRaw = function(tag, from) { - var any = tag == '*', element = from, elements = new global.Array(), next = element.firstChild; + var any = tag == '*', element = from, elements = [ ], next = element.firstChild; any || (tag = tag.toUpperCase()); while ((element = next)) { if (element.tagName > '@' && (any || element.tagName.toUpperCase() == tag)) { @@ -765,12 +740,14 @@ slice.call(from.getElementsByTagName(tag), 0); } : function(tag, from) { - var i = -1, j = i, data = new global.Array(), - element, elements = from.getElementsByTagName(tag); + var i = -1, j = i, data = [ ], element, + elements = XML_DOCUMENT || from.nodeType == 11 ? + byTagRaw(tag, from) : from.getElementsByTagName(tag); if (tag == '*') { while ((element = elements[++i])) { - if (element.nodeName > '@') + if (element.nodeName > '@') { data[++j] = element; + } } } else { while ((element = elements[++i])) { @@ -800,7 +777,7 @@ // @return array byClassRaw = function(name, from) { - var i = -1, j = i, data = new global.Array(), element, elements = _byTag('*', from), n; + var i = -1, j = i, data = [ ], element, elements = _byTag('*', from), n; name = ' ' + (QUIRKS_MODE ? name.toLowerCase() : name) + ' '; while ((element = elements[++i])) { n = XML_DOCUMENT ? element.getAttribute('class') : element.className; @@ -935,17 +912,17 @@ for (var i in option) { Config[i] = !!option[i]; if (i == 'SIMPLENOT') { - matchContexts = new global.Object(); - matchResolvers = new global.Object(); - selectContexts = new global.Object(); - selectResolvers = new global.Object(); + matchContexts = { }; + matchResolvers = { }; + selectContexts = { }; + selectResolvers = { }; if (!Config[i]) { Config['USE_QSAPI'] = false; } } else if (i == 'USE_QSAPI') { Config[i] = !!option[i] && NATIVE_QSAPI; } } setIdentifierSyntax(); - reValidator = new global.RegExp(Config.SIMPLENOT ? + reValidator = RegExp(Config.SIMPLENOT ? standardValidator : extendedValidator); return true; }, @@ -953,13 +930,13 @@ // control user notifications emit = function(message) { - if (Config.VERBOSITY) { throw new global.Error(message); } - if (global.console && global.console.log) { - global.console.log(message); + if (Config.VERBOSITY) { throw Error(message); } + if (console && console.log) { + console.log(message); } }, - Config = new global.Object({ + Config = { // used to enable/disable caching of result sets CACHING: false, @@ -998,7 +975,7 @@ // controls the engine error/warning notifications VERBOSITY: true - }), + }, /*---------------------------- COMPILER METHODS ----------------------------*/ @@ -1070,7 +1047,7 @@ ')+'; // only allow simple selectors nested in ':not()' pseudo-classes - reSimpleNot = new global.RegExp('^(' + + reSimpleNot = RegExp('^(' + '(?!:not)' + '(' + prefixes + identifier + '|\\([^()]*\\))+' + @@ -1078,15 +1055,15 @@ ')$'); // split last, right most, selector group token - reSplitToken = new global.RegExp('(' + + reSplitToken = RegExp('(' + prefixes + identifier + '|' + '\\[' + attributes + '\\]|' + '\\(' + pseudoclass + '\\)|' + '\\\\.|[^\\x20\\t\\n\\r\\f>+~])+', 'g'); - reOptimizeSelector = new global.RegExp(identifier + '|^$'); + reOptimizeSelector = RegExp(identifier + '|^$'); - reSimpleSelector = new global.RegExp( + reSimpleSelector = RegExp( BUGGY_GEBTN && BUGGY_GEBCN || OPERA ? '^#?' + identifier + '$' : BUGGY_GEBTN ? '^[.#]?' + identifier + '$' : BUGGY_GEBCN ? @@ -1094,27 +1071,27 @@ '^(?:\\*|[.#]?' + identifier + ')$'); // matches class selectors - reClass = new global.RegExp('(?:\\[[\\x20\\t\\n\\r\\f]*class\\b|\\.' + identifier + ')'); + reClass = RegExp('(?:\\[[\\x20\\t\\n\\r\\f]*class\\b|\\.' + identifier + ')'); - Optimize = new global.Object({ - ID: new global.RegExp('^\\*?#(' + identifier + ')|' + skip_groups), - TAG: new global.RegExp('^(' + identifier + ')|' + skip_groups), - CLASS: new global.RegExp('^\\.(' + identifier + '$)|' + skip_groups) - }); + Optimize = { + ID: RegExp('^\\*?#(' + identifier + ')|' + skip_groups), + TAG: RegExp('^(' + identifier + ')|' + skip_groups), + CLASS: RegExp('^\\.(' + identifier + '$)|' + skip_groups) + }; - Patterns.id = new global.RegExp('^#(' + identifier + ')(.*)'); - Patterns.tagName = new global.RegExp('^(' + identifier + ')(.*)'); - Patterns.className = new global.RegExp('^\\.(' + identifier + ')(.*)'); - Patterns.attribute = new global.RegExp('^\\[' + attrmatcher + '\\](.*)'); + Patterns.id = RegExp('^#(' + identifier + ')(.*)'); + Patterns.tagName = RegExp('^(' + identifier + ')(.*)'); + Patterns.className = RegExp('^\\.(' + identifier + ')(.*)'); + Patterns.attribute = RegExp('^\\[' + attrmatcher + '\\](.*)'); - Tokens.identifier = identifier, - Tokens.attributes = attributes, + Tokens.identifier = identifier; + Tokens.attributes = attributes; // validator for complex selectors in ':not()' pseudo-classes extendedValidator = standardValidator.replace(pseudoclass, '.*'); // validator for standard selectors as default - reValidator = new global.RegExp(standardValidator); + reValidator = RegExp(standardValidator); }, // code string reused to build compiled functions @@ -1135,7 +1112,7 @@ source += compileSelector(parts[0], mode ? ACCEPT_NODE : 'f&&f(k);return true;', mode); } else { // for each selector in the group - var i = -1, seen = new global.Object(), token; + var i = -1, seen = { }, token; while ((token = parts[++i])) { token = token.replace(reTrimSpaces, ''); // avoid repeating the same token @@ -1148,11 +1125,11 @@ if (mode) { // for select method - return new global.Function('c,s,r,d,h,g,f,v', + 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 { // for match method - return new global.Function('e,s,r,d,h,g,f,v', + return Function('e,s,r,d,h,g,f,v', 'var N,n,x=0,k=e;' + source + 'return false;'); } }, @@ -1325,8 +1302,8 @@ b = 1; } else { // assumes correct "an+b" format, "b" before "a" to keep "n" values - 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); + 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; } @@ -1564,7 +1541,7 @@ matchContexts[selector] = from; } - return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, new global.Object()); + return matchResolvers[selector](element, Snapshot, [ ], doc, root, from, callback, { }); }, // select only the first element @@ -1679,8 +1656,8 @@ if ((element = _byId(token, from))) { if (match(element, selector)) { callback && callback(element); - elements = new global.Array(element); - } else elements = new global.Array(); + elements = [element]; + } else elements = [ ]; } } @@ -1689,13 +1666,13 @@ if ((element = _byId(token, doc))) { if ('#' + token == selector) { callback && callback(element); - elements = new global.Array(element); + elements = [element]; } else if (/[>+~]/.test(selector)) { from = element.parentNode; } else { from = element; } - } else elements = new global.Array(); + } else elements = [ ]; } if (elements) { @@ -1716,7 +1693,7 @@ else if ((parts = selector.match(Optimize.CLASS)) && (token = parts[1])) { if ((elements = _byClass(token, from)).length === 0) { return [ ]; } - for (i = 0, els = new global.Array(); elements.length > i; ++i) { + for (i = 0, els = [ ]; elements.length > i; ++i) { els = concatList(els, elements[i].getElementsByTagName('*')); } elements = els; @@ -1732,7 +1709,11 @@ } if (!elements) { - elements = /^(?:applet|object)$/i.test(from.nodeName) ? from.children : _byTag('*', from); + if (IE_LT_9) { + elements = /^(?:applet|object)$/i.test(from.nodeName) ? from.children : byTagRaw('*', from); + } else { + elements = from.getElementsByTagName('*'); + } } // end of prefiltering pass @@ -1742,7 +1723,7 @@ selectContexts[selector] = from; } - elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, new global.Object()); + elements = selectResolvers[selector](elements, Snapshot, [ ], doc, root, from, callback, { }); Config.CACHING && Dom.saveResults(original, from, doc, elements); @@ -1755,15 +1736,15 @@ FN = function(x) { return x; }, // compiled match functions returning booleans - matchContexts = new global.Object(), - matchResolvers = new global.Object(), + matchContexts = { }, + matchResolvers = { }, // compiled select functions returning collections - selectContexts = new global.Object(), - selectResolvers = new global.Object(), + selectContexts = { }, + selectResolvers = { }, // used to pass methods to compiled functions - Snapshot = new global.Object({ + Snapshot = { // element indexing methods nthElement: nthElement, @@ -1787,107 +1768,113 @@ // selection/matching select: select, match: match - }); + }, /*------------------------------- PUBLIC API -------------------------------*/ // code referenced by extensions - Dom.ACCEPT_NODE = ACCEPT_NODE; + Dom = { - // retrieve element by id attr - Dom.byId = byId; + ACCEPT_NODE: ACCEPT_NODE, - // retrieve elements by tag name - Dom.byTag = byTag; + // retrieve element by id attr + byId: byId, - // retrieve elements by name attr - Dom.byName = byName; + // retrieve elements by tag name + byTag: byTag, - // retrieve elements by class name - Dom.byClass = byClass; + // retrieve elements by name attr + byName: byName, - // read the value of the attribute - // as was in the original HTML code - Dom.getAttribute = getAttribute; + // retrieve elements by class name + byClass: byClass, - // check for the attribute presence - // as was in the original HTML code - Dom.hasAttribute = hasAttribute; + // read the value of the attribute + // as was in the original HTML code + getAttribute: getAttribute, - // element match selector, return boolean true/false - Dom.match = match; + // check for the attribute presence + // as was in the original HTML code + hasAttribute: hasAttribute, - // first element match only, return element or null - Dom.first = first; + // element match selector, return boolean true/false + match: match, - // elements matching selector, starting from element - Dom.select = select; + // first element match only, return element or null + first: first, - // compile selector into ad-hoc javascript resolver - Dom.compile = compile; + // elements matching selector, starting from element + select: select, - // check that two elements are ancestor/descendant - Dom.contains = contains; + // compile selector into ad-hoc javascript resolver + compile: compile, - // handle selector engine configuration settings - Dom.configure = configure; + // check that two elements are ancestor/descendant + contains: contains, - // initialize caching for each document - Dom.setCache = FN; + // handle selector engine configuration settings + configure: configure, - // load previously collected result set - Dom.loadResults = FN; + // initialize caching for each document + setCache: FN, - // save previously collected result set - Dom.saveResults = FN; + // load previously collected result set + loadResults: FN, - // handle missing context in selector strings - Dom.shortcuts = FN; + // save previously collected result set + saveResults: FN, - // log resolvers errors/warnings - Dom.emit = emit; + // handle missing context in selector strings + shortcuts: FN, - // options enabing specific engine functionality - Dom.Config = Config; + // log resolvers errors/warnings + emit: emit, - // pass methods references to compiled resolvers - Dom.Snapshot = Snapshot; + // options enabing specific engine functionality + Config: Config, - // operators descriptor - // for attribute operators extensions - Dom.Operators = Operators; + // pass methods references to compiled resolvers + Snapshot: Snapshot, - // selectors descriptor - // for pseudo-class selectors extensions - Dom.Selectors = Selectors; + // operators descriptor + // for attribute operators extensions + Operators: Operators, - // export validators REs - Dom.Tokens = Tokens; + // selectors descriptor + // for pseudo-class selectors extensions + Selectors: Selectors, - // export version string - Dom.Version = version; + // export validators REs + Tokens: Tokens, - // add or overwrite user defined operators - Dom.registerOperator = - function(symbol, resolver) { - Operators[symbol] || (Operators[symbol] = resolver); - }; + // export version string + Version: version, - // add selector patterns for user defined callbacks - Dom.registerSelector = - function(name, rexp, func) { - Selectors[name] || (Selectors[name] = new global.Object({ - Expression: rexp, - Callback: func - })); - }; + // add or overwrite user defined operators + registerOperator: + function(symbol, resolver) { + Operators[symbol] || (Operators[symbol] = resolver); + }, + + // add selector patterns for user defined callbacks + registerSelector: + function(name, rexp, func) { + Selectors[name] || (Selectors[name] = { + Expression: rexp, + Callback: func + }); + } + + }; /*---------------------------------- INIT ----------------------------------*/ // init context specific variables initialize(doc); + + return Dom; }); - + provide("nwmatcher", module.exports(this)); !function (doc, $) {