Permalink
Browse files

Merge pull request #66 from rvagg/forms

use forms as contexts, closes #65
  • Loading branch information...
2 parents 69a6149 + ca2e581 commit 27c1f3fe42fa698c59e6e861de690eedf041b07e @ded committed Dec 13, 2011
Showing with 13 additions and 3 deletions.
  1. +1 −1 src/qwery.js
  2. +6 −2 tests/index.html
  3. +6 −0 tests/tests.js
View
@@ -239,7 +239,7 @@
function normalizeRoot(root) {
if (!root) return doc
if (typeof root == 'string') return qwery(root)[0]
- if (arrayLike(root)) return root[0]
+ if (!root.nodeType && arrayLike(root)) return root[0]
return root
}
View
@@ -17,7 +17,7 @@
return 'success'
}
</script>
- <script src="../qwery.min.js"></script>
+ <script src="../src/qwery.js"></script>
<script src="../src/pseudos.js"></script>
<script type="text/javascript">
var Q = qwery.noConflict()
@@ -118,14 +118,18 @@ <h1>Qwery Tests</h1>
<div class="sibling-selector"></div>
</div>
</div>
-
<div class="parent">
<h1 class="sibling oldest"></h1>
<h2 class="sibling older"></h2>
<h3 class="sibling middle"></h3>
<h4 class="sibling younger"></h4>
<h5 class="sibling youngest"></h5>
</div>
+ <form>
+ <button></button>
+ <input type="text">
+ <input type="hidden">
+ </form>
</div>
<ol id="tests"></ol>
<iframe id="frame" style="width: 0; height: 0; margin-left: -1000px;"></iframe>
View
@@ -278,6 +278,7 @@ sink('Uniq', function (test, ok) {
})
})
+
sink('element-context queries', function(test, ok) {
test('relationship-first queries', 5, function() {
var pass = false
@@ -320,6 +321,11 @@ sink('element-context queries', function(test, ok) {
test('exclude self in match', 1, function() {
ok(Q('.order-matters', Q('#order-matters')).length == 4, 'should not include self in element-context queries')
});
+
+ // because form's have .length
+ test('forms can be used as contexts', 1, function() {
+ ok(Q('*', Q('form')[0]).length === 3, 'found 3 elements under &lt;form&gt;')
+ })
})
sink('tokenizer', function (test, ok) {

0 comments on commit 27c1f3f

Please sign in to comment.