Skip to content

Commit

Permalink
bugfix: pass context to Sizzle; added spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
bryfox committed Aug 20, 2010
1 parent ad0c5d9 commit c4ef1de
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions spec/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ <h2 id="qunit-userAgent"></h2>
<ol id="qunit-testrunner-toolbar"></ol>

<div id="test-elements">
<div id="find_tests">
<div class="foo">first</div>
<div id="find_tests_inner">
<div class="foo">second</div>
</div>
</div>

<div id="selector_tests">
<ul id="items">
<li class="item" id="item_1">this is item one</li>
Expand Down
16 changes: 16 additions & 0 deletions spec/tests/core-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
function CoreTests() { return this; };
CoreTests.prototype.run = function () {
// ---
/// base.js specs
// ---

module("Traversal with find method", {
setup:function() {
x = x$('#find_tests_inner').find('.foo');
},
teardown:function() {
x = null;
}
});
test( 'should properly set the context', function(){
equals(x[0].innerHTML, 'second');
});

// ---
/// dom.js specs
// ---
Expand Down
2 changes: 1 addition & 1 deletion src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ xui.fn = xui.prototype = {
} else {
// one selector, check if Sizzle is available and use it instead of querySelectorAll.
if (window.Sizzle !== undefined) {
ele = Sizzle(q);
ele = Sizzle(q, context);
} else {
ele = context.querySelectorAll(q);
}
Expand Down

0 comments on commit c4ef1de

Please sign in to comment.