Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

traversty

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

traversty - npm Package Compare versions

Comparing version
1.0.2
to
1.0.3
+56
build.js
var fs = require('fs')
, gz = require('zlib').gzip
, colorsTmpl = require('colors-tmpl')
, uglify = require('uglify-js')
, inFile = 'traversty.js'
, outFile = 'traversty.min.js'
, readme = 'README.md'
, readmeContents = fs.readFileSync(readme).toString()
, rawContents = fs.readFileSync(inFile)
, copyright = rawContents.toString().match(/\/\*[\s\S]+?\*\//i)[0]
, minContentsPrev = fs.readFileSync(outFile)
, minContents = copyright + '\n' + uglify(rawContents.toString())
, sizes = {
raw: rawContents.length
, minPrev: minContentsPrev.length
, min: minContents.length
}
, s2s = function (size) {
size = Math.round(size / 1024 * 10) / 10;
return size + ' kB'
}
sizes.min = minContents.length
gz(minContentsPrev, function (err, gzContentsPrev) {
if (err) throw err;
gz(minContents, function (err, gzContents) {
if (err) throw err;
sizes.gz = gzContents.length
sizes.gzPrev = gzContentsPrev.length
for (var p in sizes) {
readmeContents = readmeContents.replace(
new RegExp(
'(?:(?:[\\d\\.]*|NaN)\\s*kB)\\s*(' + p + ')'
, 'g')
, s2s(sizes[p]) + ' $1');
}
fs.writeFileSync(outFile, minContents)
fs.writeFileSync(readme, readmeContents)
console.log(colorsTmpl(
'{bold}{green}Build successful!{/green}{/bold}\n'
+ '\t{yellow}Previous min size:{/yellow} ' + sizes.minPrev + ' bytes\n'
+ '\t{green}New min size :{/green} ' + sizes.min + ' bytes\n'
+ '\t{yellow}Previous gz size :{/yellow} ' + sizes.gzPrev + ' bytes\n'
+ '\t{green}New gz size :{/green} ' + sizes.gz + ' bytes'
))
})
})
+13
-13

@@ -6,18 +6,18 @@ var config = module.exports

, sources: [
'./test/vendor/qwery.js'
, './test/vendor/qwery_pseudos.js'
, './test/vendor/sizzle.js'
, './test/vendor/nwmatcher.js'
, './test/vendor/zest.js'
, './test/vendor/es5-basic_mod.js'
, './test/vendor/sel.js'
, './test/noconflict.js'
, './traversty.js'
, './test/setup.js'
, './test/traversal.js'
, './test/filters.js'
'test/vendor/qwery.js'
, 'test/vendor/qwery_pseudos.js'
, 'test/vendor/sizzle.js'
, 'test/vendor/nwmatcher.js'
, 'test/vendor/zest.js'
, 'test/vendor/es5-basic_mod.js'
, 'test/vendor/sel.js'
, 'test/noconflict.js'
, 'traversty.js'
, 'test/setup.js'
, 'test/traversal.js'
, 'test/filters.js'
]
, tests: [
'./test/*-test.js'
'test/*-test.js'
]
}
{
"name" : "traversty"
, "description" : "Library agnostic utility for DOM collection management and traversal"
, "version" : "1.0.2"
, "version" : "1.0.3"
, "homepage" : "https://github.com/rvagg/traversty"

@@ -18,4 +18,6 @@ , "authors" : [

"buster" : "*"
, "uglify-js" : "*"
, "colors-tmpl" : "*"
}
, "license" : "MIT"
}
+31
-28
# Traversty — headache-free DOM collection management and traversal
Traversty is a library-agnostic DOM utility for traversal and element collection manipulation. Traversty doesn't provide any DOM manipulation features, instead, Traversty is used for managing collections of DOM elements and navigating the DOM.
Traversty is a library-agnostic DOM utility for traversal and element collection manipulation. Traversty doesn't provide any DOM manipulation features; instead, Traversty is used for managing collections of DOM elements and navigating the DOM.
**Current file size:** 15.7 kB raw, 5.7 kB min, **2.1 kB gzip**
<a href="#api"><i>Just show me the API!</i></a>

@@ -35,3 +37,3 @@

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.
Wiring in a selector engine is up 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.

@@ -45,3 +47,3 @@ ```js

This bit of crazyness comes from Traversty's integration tests. The bulk of this code is used to test Traversty's integration with Ender where the `css()` method is provided by [Bonzo](https://github.com/ded/bonzo) but there is also a [vanilla version](https://github.com/rvagg/traversty/blob/master/test/integration/traversty_css_qwery.html) with only [Qwery](https://github.com/ded/qwery) for the selector engine and a `css()` method added using Traversty's <a href="#aug"><code>aug()</code></a> method (see the [/examples/aug-css.js](https://github.com/rvagg/traversty/blob/master/examples/aug-css.js) file for how this is done).
This bit of craziness comes from Traversty's integration tests. The bulk of this code is used to test Traversty's integration with Ender where the `css()` method is provided by [Bonzo](https://github.com/ded/bonzo) but there is also a [vanilla version](https://github.com/rvagg/traversty/blob/master/test/integration/traversty_css_qwery.html) with only [Qwery](https://github.com/ded/qwery) for the selector engine and a `css()` method added using Traversty's <a href="#aug"><code>aug()</code></a> method (see the [/examples/aug-css.js](https://github.com/rvagg/traversty/blob/master/examples/aug-css.js) file for how this is done).

@@ -51,3 +53,3 @@ ```js

$.setSelectorEngine(qwery)
$('#fixtures > ul') // Traversty operates on collecitons of elements
$('#fixtures > ul') // Traversty operates on collections of elements
.down(0).css('color', 'red')

@@ -133,7 +135,7 @@ .next('li', 1).css('color', 'green')

```js
traversty('li:first-child').next();
traversty('li:first-child').next()
// → returns the second `<li>` of every list in the document
traversty('li.allstarts').next('li', 1);
traversty('li.allstarts').next('li', 1)
// → returns the `nextSibling` of the `nextSibling` of the starting elements
traversty('li:first-child').next('li');
traversty('li:first-child').next('li')
// → returns all `<li>` elements, except for the first-children of every lits in the document

@@ -155,7 +157,7 @@ ```

```js
traversty('li:nth-child(20)').previous();
traversty('li:nth-child(20)').previous()
// → returns 19th child of the every list in the document (where it exists)
traversty('li.allstarts').previous('li', 1);
traversty('li.allstarts').previous('li', 1)
// → returns the `previousSibling` of the `previousSibling` of the starting element
traversty('li:nth-child(20)').previous('.interesting');
traversty('li:nth-child(20)').previous('.interesting')
// → returns all `<li>` elements with class "interesting" up to the 19th child of every list

@@ -189,7 +191,7 @@ // in the document where there are at least 20 children.

```js
traversty('li#start').up();
traversty('li#start').up()
// → returns the `<ul>` parent element
traversty('li.allstarts').up('ul', 1);
traversty('li.allstarts').up('ul', 1)
// → returns the grandparent `<ul>` elements if the start elements are nested at two levels
traversty('li.allstarts').up('ul');
traversty('li.allstarts').up('ul')
// → returns all ancestor `<ul>` elements, no matter how deep the nesting

@@ -224,3 +226,3 @@ ```

### down([selector [, index = 0]])
<code>traversty(elements).down()</code> returns a new Traversty instance containing descendent elements according to the arguments provided.
<code>traversty(elements).down()</code> returns a new Traversty instance containing descendant elements according to the arguments provided.

@@ -266,3 +268,3 @@ * `selector` *(String)* is an optional CSS selector

### children([selector [, index = 0]])
<code>traversty(elements).children()</code> returns a new Traversty instance containing direct descendent (child) elements according to the arguments provided.
<code>traversty(elements).children()</code> returns a new Traversty instance containing direct descendant (child) elements according to the arguments provided.

@@ -291,3 +293,3 @@ ```html

// → will give you *only* the second level `<ul>` element as it's
// the only direct descendent of the top `<li>` elements
// the only direct descendant of the top `<li>` elements
traversty('#root > li').children().children()

@@ -395,3 +397,3 @@ // → will give you *only* the second level `<li>` elements and none

var els = traversty('#root *')
// → start off with all 12 descendent elements under #root
// → start off with all 12 descendant elements under #root
els = els.filter('li')

@@ -418,7 +420,7 @@ // → returns only the 8 `<li>` elements within the collection

### has(selector | element)
<code>traversty(elements).has()</code> returns a new Traversty instance containing *only* the elements that have descendent elements that match the provided `selector` argument, or have `element` as a descendent element.
<code>traversty(elements).has()</code> returns a new Traversty instance containing *only* the elements that have descendant elements that match the provided `selector` argument, or have `element` as a descendant element.
If a `selector` string argument is provided, each element in the collection effectively has a `find(selector)`-type operation performed on it, if any matching descendent elements are found, the parent element is retained for the new collection; otherwise it is not included.
If a `selector` string argument is provided, each element in the collection effectively has a `find(selector)`-type operation performed on it, if any matching descendant elements are found, the parent element is retained for the new collection; otherwise it is not included.
If an `element` argument is provided then the only element included in the resulting collection is an ancestor of that `element`, if the `element` is not a descendent of any of the elements in the collection then the resulting collection will be empty.
If an `element` argument is provided then the only element included in the resulting collection is an ancestor of that `element`, if the `element` is not a descendant of any of the elements in the collection then the resulting collection will be empty.

@@ -446,5 +448,5 @@ ```html

var els = traversty('#root *')
// → start off with all 12 descendent elements under #root
// → start off with all 12 descendant elements under #root
els = els.has('li')
// → returns a collection of 4 elements which have `<li>` descendents: the 'first' `<li>`,
// → returns a collection of 4 elements which have `<li>` descendants: the 'first' `<li>`,
// the `<ul>` directly under it, the 'ii' `<li>` and the `<ul>` directly under that.

@@ -454,3 +456,3 @@ els.has(traversty('#root a')[0])

// which we pass in to `has()`. There are two elements that have this single element
// as a descendent, the 'first' `<li>` element and the `<ul>` directly under it.
// as a descendant, the 'first' `<li>` element and the `<ul>` directly under it.
```

@@ -561,8 +563,8 @@

select: function(selector, root) {
return MyEngine(selector, root);
return MyEngine(selector, root)
}
, is: function(selector, root) {
return MyEngine(root).isTheSameAs(selector);
return MyEngine(root).isTheSameAs(selector)
}
});
})
```

@@ -591,3 +593,3 @@

* Traversty always does a **uniqueness** check on its collection of elements so you should never end up with duplicates. If you do a `traversty('body,ul').down('li')` you would still only get a unique list of all *<li>* elements in the document.
* Traversty always does a **uniqueness** check on its collection of elements so you should never end up with duplicates. If you do a `traversty('body,ul').down('li')` you would still only get a unique list of all <code>&lt;li&gt;</code> elements in the document.

@@ -629,3 +631,4 @@ * Traversty ignores text and comment nodes and should only ever operate on the DOM element nodes you would expect (i.e. with `.nodeType === 1`).

* Firstly, much credit should go to the awesome Prototype guys and their excellent API that I've ripped off.
* Firstly, much credit should go to the awesome Prototype guys and their excellent API that I initially ripped off for Traversty 0.x.
* Obviously, kudos goes to John Resig and the jQuery team for their traversal and filtering API that I've so shamelessly ripped off.
* Thanks to [@ded](http://github.com/ded) and [@fat](http://github.com/fat) for Ender, particularly @ded for Bonzo, upon which Traversty is designed to build.

@@ -632,0 +635,0 @@

@@ -8,7 +8,7 @@ /***************************************************************

!(function (name, definition) {
if (typeof module !== 'undefined') module.exports = definition()
else if (typeof define === 'function' && define.amd) define(name, definition)
else this[name] = definition()
}('traversty', function () {
(function (name, context, definition) {
if (typeof module != 'undefined' && module.exports) module.exports = definition()
else if (typeof define == 'function' && define.amd) define(definition)
else context[name] = definition()
})('traversty', this, function () {

@@ -25,3 +25,4 @@ var context = this

while (i < pfx.length)
if (el[ms = pfx[i++] + name]) return ms
if (el[ms = pfx[i++] + name])
return ms
}(html, [ 'msM', 'webkitM', 'mozM', 'oM', 'm' ], 'atchesSelector', 0))

@@ -81,5 +82,5 @@

var ret = [], i = -1, els = el.getElementsByTagName('*')
while (++i < els.length) {
if (isElement(els[i]) && selectorMatches(selector, els[i])) ret.push(els[i])
}
while (++i < els.length)
if (isElement(els[i]) && selectorMatches(selector, els[i]))
ret.push(els[i])
return ret

@@ -102,3 +103,5 @@ }

: function (element, container) { // old smelly browser
while (element = element.parentNode) if (element === container) return 1
while (element = element.parentNode)
if (element === container)
return 1
return 0

@@ -119,3 +122,4 @@ }

}
if (!has) a.push(ar[i])
if (!has)
a.push(ar[i])
}

@@ -131,3 +135,4 @@ return a

l2 = (res = fn(els[i], i++)).length
while (j < l2) ret.push(res[j++])
while (j < l2)
ret.push(res[j++])
}

@@ -166,4 +171,6 @@ return ret

, eqIndex = function (length, index, def) {
if (index < 0) index = length + index
if (index < 0 || index >= length) return null
if (index < 0)
index = length + index
if (index < 0 || index >= length)
return null
return !index && index !== 0 ? def : index

@@ -176,3 +183,4 @@ }

for (; i < l; i++)
fn(els[i], i) && arr.push(els[i])
if (fn(els[i], i))
arr.push(els[i])
return arr

@@ -207,3 +215,4 @@ }

var i = this.length = els.length
while (i--) this[i] = els[i]
while (i--)
this[i] = els[i]
}

@@ -256,6 +265,9 @@ }

, i = 0, l = arr.length
for (; i < l; i++) {
arr[i] = arr[i].parentNode.firstChild
while (!isElement(arr[i])) arr[i] = arr[i].nextSibling
while (!isElement(arr[i]))
arr[i] = arr[i].nextSibling
}
if (isUndefined(selector))

@@ -325,3 +337,4 @@ selector = '*'

for (; i < l; i++)
if (fn(this[i], i)) return true
if (fn(this[i], i))
return true
return false

@@ -358,5 +371,4 @@ }

method = methods[key]
if (typeof method == 'function') {
if (typeof method == 'function')
T.prototype[key] = method
}
}

@@ -395,3 +407,3 @@ }

_selectorMatches = isFunction(ss._is)
? function (selector, el) { return s(el)._is(selector) } // original .is(), replaced by Enderbridge
? function (selector, el) { return s(el)._is(selector) } // original .is(), replaced by Ender bridge
: isFunction(ss.matching)

@@ -418,6 +430,9 @@ ? function (selector, el) { return s(el).matching(selector).length > 0 }

// basic select
if ((r = select('b,a', e)).length !== 2) throw new Error('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
// and if not, work around it
_selectorFind = r[0] === a ? select : createUnorderedEngineSelectorFind(select, _selectorMatches)
// have we done enough to get a working `selectorFind`?

@@ -430,4 +445,5 @@ if ((r = _selectorFind('b,a', e)).length !== 2 || r[0] !== a)

} catch (ex) {
if (isString(ex)) throw ex
throw new Error('Traversty: error while figuring out how the selector engine works: ' + (ex.message || ex))
throw isString(ex)
? ex
: new Error('Traversty: error while figuring out how the selector engine works: ' + (ex.message || ex))
} finally {

@@ -449,2 +465,2 @@ e = null

return traversty
}));
});

@@ -6,2 +6,3 @@ /***************************************************************

* 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,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});
*/
(function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("traversty",this,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})
.PHONY: build test server
build:
@echo "Minified size before: "
@echo -n "\t"
@du -b ./traversty.min.js
@gzip ./traversty.min.js
@echo -n "\t"
@du -b ./traversty.min.js.gz
@gunzip ./traversty.min.js.gz
@jshint ./traversty.js
@uglifyjs ./traversty.js > ./traversty.min.js
@echo "Minified size after: "
@echo -n "\t"
@du -b ./traversty.min.js
@gzip ./traversty.min.js
@echo -n "\t"
@du -b ./traversty.min.js.gz
@gunzip ./traversty.min.js.gz
test:
buster test -R
server:
buster server &