diff --git a/CHANGELOG b/CHANGELOG index 0db64ed..df69992 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,5 @@ *SVN* +* Fix Selector.matchElements to allow for coma-separated selectors in Element#up/next/previous and Event#findElement. [Samuel Lebeau, Tobie Langel] * Test.Unit refactoring. Allow running multiple instances of Test.Unit.Runner on the same page. Allow rake to run specific testcases (e.g.: rake test BROWSERS=firefox TESTS=array TESTCASES=testUniq,test$w). Closes #10704, #10705, #10706. [nicwilliams, Tobie Langel] diff --git a/src/selector.js b/src/selector.js index d487b57..5453f15 100644 --- a/src/selector.js +++ b/src/selector.js @@ -618,7 +618,7 @@ Object.extend(Selector, { }, matchElements: function(elements, expression) { - var matches = new Selector(expression).findElements(), h = Selector.handlers; + var matches = $$(expression), h = Selector.handlers; h.mark(matches); for (var i = 0, results = [], element; element = elements[i]; i++) if (element._counted) results.push(element); diff --git a/test/lib/unittest.js b/test/lib/unittest.js index 561eebe..5b57753 100644 --- a/test/lib/unittest.js +++ b/test/lib/unittest.js @@ -445,8 +445,8 @@ Test.Unit.Assertions = { Test.Unit.Testcase = Class.create(Test.Unit.Assertions, { initialize: function(name, test, setup, teardown) { this.name = name; - this.test = test || Prototype.emptyFunction; - this.setup = setup || Prototype.emptyFunction; + this.test = test || Prototype.emptyFunction; + this.setup = setup || Prototype.emptyFunction; this.teardown = teardown || Prototype.emptyFunction; this.messages = []; this.actions = {}; diff --git a/test/unit/dom.html b/test/unit/dom.html index 0588a78..0828ad5 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -942,6 +942,7 @@ assertElementMatches(element.up('ul', 1), 'ul#navigation_test'); assertEqual(undefined, element.up('garbage')); assertEqual(undefined, element.up(6)); + assertElementMatches(element.up('.non-existant, ul'), 'ul'); var dummy = $(document.createElement('DIV')); dummy.innerHTML = '
'.times(3); @@ -955,6 +956,7 @@ assertElementMatches(element.down(1), 'em'); assertElementMatches(element.down('li', 5), 'li.last'); assertElementMatches(element.down('ul').down('li', 1), 'li#navigation_test_f'); + assertElementMatches(element.down('.non-existant, .first'), 'li.first'); var dummy = $(document.createElement('DIV')); dummy.innerHTML = '
'.times(3); @@ -968,6 +970,7 @@ assertElementMatches(element.previous('.first'), 'li.first'); assertEqual(undefined, element.previous(3)); assertEqual(undefined, $('navigation_test').down().previous()); + assertElementMatches(element.previous('.non-existant, .first'), 'li.first'); var dummy = $(document.createElement('DIV')); dummy.innerHTML = '
'.times(3); @@ -982,6 +985,7 @@ assertElementMatches(element.next('.last'), 'li.last'); assertEqual(undefined, element.next(3)); assertEqual(undefined, element.next(2).next()); + assertElementMatches(element.next('.non-existant, .last'), 'li.last'); var dummy = $(document.createElement('DIV')); dummy.innerHTML = '
'.times(3); diff --git a/test/unit/event.html b/test/unit/event.html index d96f7df..18372fa 100644 --- a/test/unit/event.html +++ b/test/unit/event.html @@ -235,13 +235,12 @@ testEventFindElement: function() { with(this) { var span = $("span"), event; event = span.fire("test:somethingHappened"); - assertEqual(span, event.findElement()); - assertEqual(span, event.findElement('span')); - assertEqual($("inner"), event.findElement('p')); + assertElementMatches(event.findElement(), 'span#span'); + assertElementMatches(event.findElement('span'), 'span#span'); + assertElementMatches(event.findElement('p'), 'p#inner'); assertEqual(null, event.findElement('div.does_not_exist')); + assertElementMatches(event.findElement('.does_not_exist, span'), 'span#span'); }} - - }); document.observe("dom:loaded", function(event) { diff --git a/test/unit/selector.html b/test/unit/selector.html index d6f0b33..3c1383d 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -215,6 +215,7 @@ assertElementsMatch(Selector.matchElements($('list').descendants(), 'li'), '#item_1', '#item_2', '#item_3'); assertElementsMatch(Selector.matchElements($('fixtures').descendants(), 'a.internal'), '#link_1', '#link_2'); assertEnumEqual([], Selector.matchElements($('fixtures').descendants(), 'p.last')); + assertElementsMatch(Selector.matchElements($('fixtures').descendants(), '.inexistant, a.internal'), '#link_1', '#link_2'); }}, testSelectorFindElement: function() {with(this) {