Skip to content
Browse files

update component integration & docs

  • Loading branch information...
1 parent 50388c0 commit e0c41b1f8dfbcc9f707d5c7378049bb9005c81d4 @rvagg committed
Showing with 14 additions and 17 deletions.
  1. +12 −1 README.md
  2. +2 −3 component.json
  3. +0 −13 index.js
View
13 README.md
@@ -16,18 +16,29 @@ Traversty operates on DOM element collections, jQuery-style, so it also gives yo
Traversty emulates an Array and includes additional methods to help you manage it as if it were one: <a href="#get"><code>get()</code></a>, <a href="#toArray"><code>toArray()</code></a>, <a href="#size"><code>size()</code></a>, <a href="#push"><code>push()</code></a>, <a href="#sort"><code>sort()</code></a>, <a href="#splice"><code>splice()</code></a>.
+### 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
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).
@@ -517,7 +528,7 @@ traversty('li').append(span)
--------------------------------------------------------
<a name="setSelectorEngine"></a>
### 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)`.
## Selector engines
View
5 component.json
@@ -12,10 +12,9 @@
]
, "dependencies" : {}
, "development" : {}
- , "main" : "index.js"
+ , "main" : "./traversty.js"
, "scripts": [
- "index.js"
- , "traversty.js"
+ "./traversty.js"
]
, "license" : "MIT"
}
View
13 index.js
@@ -1,13 +0,0 @@
-// for component: https://github.com/component/component
-
-var T = module.exports = require('./traversty')
- , engines = [ 'zest', 'qwery', 'jquery', 'sizzle' ]
- , i = 0
- , l = engines.length
-
-for (; i < l; i++) {
- try {
- T.setSelectorEngine(require(engines[i]))
- break
- } catch (e) {}
-}

0 comments on commit e0c41b1

Please sign in to comment.
Something went wrong with that request. Please try again.