Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

byId fixes and feature additions #61

Merged
merged 3 commits into from Dec 12, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/qwery.js
Expand Up @@ -104,6 +104,7 @@
// div.hello[title="world"]:foo('bar'), div, .hello, [title="world"], title, =, world, :foo('bar'), foo, ('bar'), bar]
function interpret(whole, tag, idsAndClasses, wholeAttribute, attribute, qualifier, value, wholePseudo, pseudo, wholePseudoVal, pseudoVal) {
var i, m, k, o, classes
if (this.nodeType !== 1) return false
if (tag && tag !== '*' && this.tagName && this.tagName.toLowerCase() !== tag) return false
if (idsAndClasses && (m = idsAndClasses.match(id)) && m[1] !== this.id) return false
if (idsAndClasses && (classes = idsAndClasses.match(clas))) {
Expand Down Expand Up @@ -357,7 +358,7 @@
}
// no native selector support
, selectNonNative = function (selector, root) {
var result = [], m, i, l, r, ss
var result = [], items, m, i, l, r, ss
selector = selector.replace(normalizr, '$1')
if (m = selector.match(tagAndOrClass)) {
r = classRegex(m[2])
Expand Down
4 changes: 4 additions & 0 deletions tests/index.html
Expand Up @@ -52,11 +52,15 @@ <h1>Qwery Tests</h1>
<div class="a"></div>
<div class="class-with-dashes"></div>
<div id="boosh">
<!-- comment -->
<!-- comment -->
<div class="a b">
<div class="d e" test="fg" id="booshTest"></div>
<!-- comment -->
<em nopass="copyrighters" rel="copyright booshrs" test="f g"></em>
<span class="h i a"></span>
</div>
<!-- comment -->
</div>
<div id="lonelyBoosh"></div>
<div id="attr-test1" -data-attr></div>
Expand Down
8 changes: 6 additions & 2 deletions tests/tests.js
Expand Up @@ -75,6 +75,10 @@ sink('CSS 1', function (test, ok) {
ok(Q('.class-with-dashes').length == 1, 'found something');
});

test('should ignore comment nodes', 1, function() {
ok(Q('#boosh *').length === 4, 'found only 4 elements under #boosh')
});

test('deep messy relationships', 6, function() {
// these are mostly characterised by a combination of tight relationships and loose relationships
// on the right side of the query it's easy to find matches but they tighten up quickly as you
Expand Down Expand Up @@ -266,7 +270,7 @@ sink('attribute selectors', function (test, ok, b, a, assert) {

});

sink('Element-context queries', function(test, ok) {
sink('element-context queries', function(test, ok) {
test('relationship-first queries', 5, function() {
var pass = false
try { pass = Q('> .direct-descend', Q('#direct-descend')).length == 2 } catch (e) { }
Expand Down Expand Up @@ -492,7 +496,7 @@ sink('argument types', function (test, ok) {

});

sink('testing is()', function (test, ok) {
sink('is()', function (test, ok) {
var el = document.getElementById('attr-child-boosh');
test('simple selectors', 9, function () {
ok(Q.is(el, 'li'), 'tag');
Expand Down