| { | ||
| "name" : "traversty" | ||
| , "repo" : "rvagg/traversty" | ||
| , "description" : "Library agnostic utility for DOM collection management and traversal" | ||
| , "version" : "1.0.1" | ||
| , "twitter" : "@rvagg" | ||
| , "keywords" : [ | ||
| "dom" | ||
| , "nodes" | ||
| , "traversal" | ||
| , "filter" | ||
| ] | ||
| , "dependencies" : {} | ||
| , "development" : {} | ||
| , "main" : "./traversty.js" | ||
| , "scripts": [ | ||
| "./traversty.js" | ||
| ] | ||
| , "license" : "MIT" | ||
| } |
+1
-1
| { | ||
| "name" : "traversty" | ||
| , "description" : "Library agnostic utility for DOM collection management and traversal" | ||
| , "version" : "1.0.1" | ||
| , "version" : "1.0.2" | ||
| , "homepage" : "https://github.com/rvagg/traversty" | ||
@@ -6,0 +6,0 @@ , "authors" : [ |
+23
-2
@@ -19,4 +19,25 @@ # Traversty — headache-free DOM collection management and traversal | ||
| ### Ender integration | ||
| Traversty is designed to be integrated in an [Ender](http://ender.no.de/) build, to augment what's already available in [Bonzo](https://github.com/ded/bonzo) but can just as easily be used as a stand-alone utility. | ||
| ``` | ||
| $ ender build jeesh traversty | ||
| ``` | ||
| ### Component integration | ||
| You can also install Traversty as a [component](https://github.com/component/component): | ||
| ``` | ||
| $ component install rvagg/traversty | ||
| ``` | ||
| Wiring up a selector engine is let to you in your component build. You'll need to make one-off call to `setSelectorEngine()` once you have a selector engine to inject, otherwise Traversty will simply use native `querySelectorAll()` and `matchesSelector()` if available. See the <a href="#setSelectorEngine"><code>setSelectorEngine()</code></a> for more details on how this works. | ||
| ```js | ||
| var zest = require('zest') | ||
| , $ = require('traversty').setSelectorEngine(zest) | ||
| ``` | ||
| ## Example usage | ||
@@ -511,3 +532,3 @@ | ||
| ### setSelectorEngine(selectorEngine) | ||
| <code>traversty.setSelectorEngine()</code> injects a selector engine for Traversty to use. See the next section for details. | ||
| <code>traversty.setSelectorEngine()</code> injects a selector engine for Traversty to use. See the next section for details. Returns the main `Traversty` object for chainability, e.g.: `var $ = traversty.setSelectorEngine(qwery)`. | ||
@@ -601,2 +622,2 @@ ## Selector engines | ||
| Traversty is Copyright (c) 2012 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. | ||
| Traversty is Copyright (c) 2012 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. |
@@ -32,3 +32,4 @@ /*global traversalTests:true, filterTests:true, buster:true, T:true, Q:true, Sizzle:true, NW:true, zest:true, sel:true, loadES5Basic:true, __matchesSelector:true*/ | ||
| try { | ||
| T.setSelectorEngine(engine) | ||
| // throwing in a 'is chainable' test here.. a bit naughty but has to be done somewhere | ||
| assert.same(T.setSelectorEngine(engine), T) | ||
| } catch(e) { | ||
@@ -35,0 +36,0 @@ buster.log(e) |
+7
-5
@@ -398,10 +398,10 @@ /*************************************************************** | ||
| if (!_selectorMatches) | ||
| throw 'Traversty: couldn\'t find selector engine\'s `matchesSelector`' | ||
| throw new Error('Traversty: couldn\'t find selector engine\'s `matchesSelector`') | ||
| // verify that we have a working `matchesSelector` | ||
| if (_selectorMatches('x,y', e) || !_selectorMatches('a,p', e)) | ||
| throw 'Traversty: couldn\'t make selector engine\'s `matchesSelector` work' | ||
| throw new Error('Traversty: couldn\'t make selector engine\'s `matchesSelector` work') | ||
| // basic select | ||
| if ((r = select('b,a', e)).length !== 2) throw 'Traversty: don\'t know how to use this selector engine' | ||
| if ((r = select('b,a', e)).length !== 2) throw new Error('Traversty: don\'t know how to use this selector engine') | ||
| // check to see if the selector engine has given us the results in document-order | ||
@@ -412,3 +412,3 @@ // and if not, work around it | ||
| if ((r = _selectorFind('b,a', e)).length !== 2 || r[0] !== a) | ||
| throw 'Traversty: couldn\'t make selector engine work' | ||
| throw new Error('Traversty: couldn\'t make selector engine work') | ||
@@ -419,6 +419,8 @@ selectorMatches = _selectorMatches | ||
| if (isString(ex)) throw ex | ||
| throw 'Traversty: error while figuring out how the selector engine works: ' + (ex.message || ex) | ||
| throw new Error('Traversty: error while figuring out how the selector engine works: ' + (ex.message || ex)) | ||
| } finally { | ||
| e = null | ||
| } | ||
| return t | ||
| } | ||
@@ -425,0 +427,0 @@ |
+1
-1
@@ -6,2 +6,2 @@ /*************************************************************** | ||
| * License: MIT | ||
| */!function(e,t){typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(e,t):this[e]=t()}("traversty",function(){var e=this,t=e.traversty,n=window.document,r=n.documentElement,i=Object.prototype.toString,s=Array.prototype,o=s.slice,u=function(e,t,n,r,i){while(r<t.length)if(e[i=t[r++]+n])return i}(r,["msM","webkitM","mozM","oM","m"],"atchesSelector",0),a=function(){return!1},f=function(e){return i.call(e)==="[object Number]"},l=function(e){return i.call(e)==="[object String]"},c=function(e){return i.call(e)==="[object Function]"},h=function(e){return e===void 0},p=function(e){return e&&e.nodeType===1},d=function(e,t){return h(e)&&!f(t)?0:f(e)?e:f(t)?t:null},v=function(e){return l(e)?e:"*"},m=function(e,t){return o.call(t.querySelectorAll(e),0)},g=function(e,t){return e==="*"||t[u](e)},y=m,b=g,w=function(e,t){return function(n,r){if(/,/.test(n)){var i=[],s=-1,o=r.getElementsByTagName("*");while(++s<o.length)p(o[s])&&t(n,o[s])&&i.push(o[s]);return i}return e(n,r)}},E="compareDocumentPosition"in r?function(e,t){return(t.compareDocumentPosition(e)&16)==16}:"contains"in r?function(e,t){return t=t.nodeType===9||t==window?r:t,t!==e&&t.contains(e)}:function(e,t){while(e=e.parentNode)if(e===t)return 1;return 0},S=function(e){var t=[],n=-1,r,i;while(++n<e.length){r=-1,i=!1;while(++r<t.length)if(t[r]===e[n]){i=!0;break}i||t.push(e[n])}return t},x=function(e,t){var n=[],r,i=0,s,o=e.length,u;while(i<o){s=0,u=(r=t(e[i],i++)).length;while(s<u)n.push(r[s++])}return n},T=function(e,t,n,r,i){return r=d(n,r),n=v(n),x(e,function(e,s){var o=r||0,u=[];i||(e=e[t]);while(e&&(r===null||o>=0))p(e)&&(!i||i===!0||i(e,s))&&b(n,e)&&(r===null||o--===0)&&(r===null&&t!=="nextSibling"?u=[e].concat(u):u.push(e)),e=e[t];return u})},N=function(e,t,n){return t<0&&(t=e+t),t<0||t>=e?null:!t&&t!==0?n:t},C=function(e,t){var n=[],r=0,i=e.length;for(;r<i;r++)t(e[r],r)&&n.push(e[r]);return n},k=function(e){var t;return p(e)?function(t){return t===e}:(t=typeof e)=="function"?function(t,n){return e.call(t,n)}:t=="string"&&e.length?function(t){return b(e,t)}:a},L=function(e){return function(){return!e.apply(this,arguments)}},A=function(){function r(e){this.length=0;if(e){e=S(!e.nodeType&&!h(e.length)?e:[e]);var t=this.length=e.length;while(t--)this[t]=e[t]}}function i(e){return new r(l(e)?y(e,n):e)}return r.prototype={down:function(e,t){return t=d(e,t),e=v(e),A(x(this,function(n){var r=y(e,n);return t===null?r:[r[t]]||[]}))},up:function(e,t){return A(T(this,"parentNode",e,t))},parents:function(){return r.prototype.up.apply(this,arguments.length?arguments:["*"])},closest:function(e,t){if(f(e))t=e,e="*";else{if(!l(e))return A([]);f(t)||(t=0)}return A(T(this,"parentNode",e,t,!0))},previous:function(e,t){return A(T(this,"previousSibling",e,t))},next:function(e,t){return A(T(this,"nextSibling",e,t))},siblings:function(e,t){var n=this,r=o.call(this,0),i=0,s=r.length;for(;i<s;i++){r[i]=r[i].parentNode.firstChild;while(!p(r[i]))r[i]=r[i].nextSibling}return h(e)&&(e="*"),A(T(r,"nextSibling",e||"*",t,function(e,t){return e!==n[t]}))},children:function(e,t){return A(T(r.prototype.down.call(this),"nextSibling",e||"*",t,!0))},first:function(){return r.prototype.eq.call(this,0)},last:function(){return r.prototype.eq.call(this,-1)},eq:function(e){return A(this.get(e))},get:function(e){return this[N(this.length,e,0)]},slice:function(e,t){var n=t,r=this.length,i=[];e=N(r,Math.max(-this.length,e),0),n=N(t<0?r:r+1,t,r),t=n===null||n>r?t<0?0:r:n;while(e!==null&&e<t)i.push(this[e++]);return A(i)},filter:function(e){return A(C(this,k(e)))},not:function(e){return A(C(this,L(k(e))))},has:function(e){return A(C(this,p(e)?function(t){return E(e,t)}:typeof e=="string"&&e.length?function(t){return y(e,t).length}:a))},is:function(e){var t=0,n=this.length,r=k(e);for(;t<n;t++)if(r(this[t],t))return!0;return!1},toArray:function(){return s.slice.call(this)},size:function(){return this.length},each:function(e,t){var n=0,r=this.length;for(;n<r;n++)e.call(t||this[n],this[n],n,this);return this},push:s.push,sort:s.sort,splice:s.splice},r.prototype.prev=r.prototype.previous,i.aug=function(e){var t,n;for(t in e)n=e[t],typeof n=="function"&&(r.prototype[t]=n)},i.setSelectorEngine=function(e){var t,r,i,s,o,u=n.createElement("p"),a=e.select||e.sel||e;u.innerHTML="<a/><i/><b/>",i=u.firstChild;try{s=c(e.matching)?function(t,n){return e.matching([n],t).length>0}:c(e.is)?function(t,n){return e.is(n,t)}:c(e.matchesSelector)?function(t,n){return e.matchesSelector(n,t)}:c(e.match)?function(t,n){return e.match(n,t)}:c(e.matches)?function(t,n){return e.matches(n,t)}:null,s||(t=e("a",u),s=c(t._is)?function(t,n){return e(n)._is(t)}:c(t.matching)?function(t,n){return e(n).matching(t).length>0}:c(t.is)&&!t.is.__ignore?function(t,n){return e(n).is(t)}:c(t.matchesSelector)?function(t,n){return e(n).matchesSelector(t)}:c(t.match)?function(t,n){return e(n).match(t)}:c(t.matches)?function(t,n){return e(n).matches(t)}:null);if(!s)throw"Traversty: couldn't find selector engine's `matchesSelector`";if(s("x,y",u)||!s("a,p",u))throw"Traversty: couldn't make selector engine's `matchesSelector` work";if((r=a("b,a",u)).length!==2)throw"Traversty: don't know how to use this selector engine";o=r[0]===i?a:w(a,s);if((r=o("b,a",u)).length!==2||r[0]!==i)throw"Traversty: couldn't make selector engine work";b=s,y=o}catch(f){throw l(f)?f:"Traversty: error while figuring out how the selector engine works: "+(f.message||f)}finally{u=null}},i.noConflict=function(){return e.traversty=t,this},i}();return A}); | ||
| */!function(e,t){typeof module!="undefined"?module.exports=t():typeof define=="function"&&define.amd?define(e,t):this[e]=t()}("traversty",function(){var e=this,t=e.traversty,n=window.document,r=n.documentElement,i=Object.prototype.toString,s=Array.prototype,o=s.slice,u=function(e,t,n,r,i){while(r<t.length)if(e[i=t[r++]+n])return i}(r,["msM","webkitM","mozM","oM","m"],"atchesSelector",0),a=function(){return!1},f=function(e){return i.call(e)==="[object Number]"},l=function(e){return i.call(e)==="[object String]"},c=function(e){return i.call(e)==="[object Function]"},h=function(e){return e===void 0},p=function(e){return e&&e.nodeType===1},d=function(e,t){return h(e)&&!f(t)?0:f(e)?e:f(t)?t:null},v=function(e){return l(e)?e:"*"},m=function(e,t){return o.call(t.querySelectorAll(e),0)},g=function(e,t){return e==="*"||t[u](e)},y=m,b=g,w=function(e,t){return function(n,r){if(/,/.test(n)){var i=[],s=-1,o=r.getElementsByTagName("*");while(++s<o.length)p(o[s])&&t(n,o[s])&&i.push(o[s]);return i}return e(n,r)}},E="compareDocumentPosition"in r?function(e,t){return(t.compareDocumentPosition(e)&16)==16}:"contains"in r?function(e,t){return t=t.nodeType===9||t==window?r:t,t!==e&&t.contains(e)}:function(e,t){while(e=e.parentNode)if(e===t)return 1;return 0},S=function(e){var t=[],n=-1,r,i;while(++n<e.length){r=-1,i=!1;while(++r<t.length)if(t[r]===e[n]){i=!0;break}i||t.push(e[n])}return t},x=function(e,t){var n=[],r,i=0,s,o=e.length,u;while(i<o){s=0,u=(r=t(e[i],i++)).length;while(s<u)n.push(r[s++])}return n},T=function(e,t,n,r,i){return r=d(n,r),n=v(n),x(e,function(e,s){var o=r||0,u=[];i||(e=e[t]);while(e&&(r===null||o>=0))p(e)&&(!i||i===!0||i(e,s))&&b(n,e)&&(r===null||o--===0)&&(r===null&&t!=="nextSibling"?u=[e].concat(u):u.push(e)),e=e[t];return u})},N=function(e,t,n){return t<0&&(t=e+t),t<0||t>=e?null:!t&&t!==0?n:t},C=function(e,t){var n=[],r=0,i=e.length;for(;r<i;r++)t(e[r],r)&&n.push(e[r]);return n},k=function(e){var t;return p(e)?function(t){return t===e}:(t=typeof e)=="function"?function(t,n){return e.call(t,n)}:t=="string"&&e.length?function(t){return b(e,t)}:a},L=function(e){return function(){return!e.apply(this,arguments)}},A=function(){function r(e){this.length=0;if(e){e=S(!e.nodeType&&!h(e.length)?e:[e]);var t=this.length=e.length;while(t--)this[t]=e[t]}}function i(e){return new r(l(e)?y(e,n):e)}return r.prototype={down:function(e,t){return t=d(e,t),e=v(e),A(x(this,function(n){var r=y(e,n);return t===null?r:[r[t]]||[]}))},up:function(e,t){return A(T(this,"parentNode",e,t))},parents:function(){return r.prototype.up.apply(this,arguments.length?arguments:["*"])},closest:function(e,t){if(f(e))t=e,e="*";else{if(!l(e))return A([]);f(t)||(t=0)}return A(T(this,"parentNode",e,t,!0))},previous:function(e,t){return A(T(this,"previousSibling",e,t))},next:function(e,t){return A(T(this,"nextSibling",e,t))},siblings:function(e,t){var n=this,r=o.call(this,0),i=0,s=r.length;for(;i<s;i++){r[i]=r[i].parentNode.firstChild;while(!p(r[i]))r[i]=r[i].nextSibling}return h(e)&&(e="*"),A(T(r,"nextSibling",e||"*",t,function(e,t){return e!==n[t]}))},children:function(e,t){return A(T(r.prototype.down.call(this),"nextSibling",e||"*",t,!0))},first:function(){return r.prototype.eq.call(this,0)},last:function(){return r.prototype.eq.call(this,-1)},eq:function(e){return A(this.get(e))},get:function(e){return this[N(this.length,e,0)]},slice:function(e,t){var n=t,r=this.length,i=[];e=N(r,Math.max(-this.length,e),0),n=N(t<0?r:r+1,t,r),t=n===null||n>r?t<0?0:r:n;while(e!==null&&e<t)i.push(this[e++]);return A(i)},filter:function(e){return A(C(this,k(e)))},not:function(e){return A(C(this,L(k(e))))},has:function(e){return A(C(this,p(e)?function(t){return E(e,t)}:typeof e=="string"&&e.length?function(t){return y(e,t).length}:a))},is:function(e){var t=0,n=this.length,r=k(e);for(;t<n;t++)if(r(this[t],t))return!0;return!1},toArray:function(){return s.slice.call(this)},size:function(){return this.length},each:function(e,t){var n=0,r=this.length;for(;n<r;n++)e.call(t||this[n],this[n],n,this);return this},push:s.push,sort:s.sort,splice:s.splice},r.prototype.prev=r.prototype.previous,i.aug=function(e){var t,n;for(t in e)n=e[t],typeof n=="function"&&(r.prototype[t]=n)},i.setSelectorEngine=function(e){var t,r,s,o,u,a=n.createElement("p"),f=e.select||e.sel||e;a.innerHTML="<a/><i/><b/>",s=a.firstChild;try{o=c(e.matching)?function(t,n){return e.matching([n],t).length>0}:c(e.is)?function(t,n){return e.is(n,t)}:c(e.matchesSelector)?function(t,n){return e.matchesSelector(n,t)}:c(e.match)?function(t,n){return e.match(n,t)}:c(e.matches)?function(t,n){return e.matches(n,t)}:null,o||(t=e("a",a),o=c(t._is)?function(t,n){return e(n)._is(t)}:c(t.matching)?function(t,n){return e(n).matching(t).length>0}:c(t.is)&&!t.is.__ignore?function(t,n){return e(n).is(t)}:c(t.matchesSelector)?function(t,n){return e(n).matchesSelector(t)}:c(t.match)?function(t,n){return e(n).match(t)}:c(t.matches)?function(t,n){return e(n).matches(t)}:null);if(!o)throw new Error("Traversty: couldn't find selector engine's `matchesSelector`");if(o("x,y",a)||!o("a,p",a))throw new Error("Traversty: couldn't make selector engine's `matchesSelector` work");if((r=f("b,a",a)).length!==2)throw new Error("Traversty: don't know how to use this selector engine");u=r[0]===s?f:w(f,o);if((r=u("b,a",a)).length!==2||r[0]!==s)throw new Error("Traversty: couldn't make selector engine work");b=o,y=u}catch(h){throw l(h)?h:new Error("Traversty: error while figuring out how the selector engine works: "+(h.message||h))}finally{a=null}return i},i.noConflict=function(){return e.traversty=t,this},i}();return A}); |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
746109
0.21%40
2.56%18222
0.12%621
3.67%