I have a page with elements similar to this:
<div id='things'>
<div class='thing'>
<div class='activator'>
<span>Some text</span>
</div>
</div>
</div>
The code is similar to this:
$('things').observe(click, function(event) {
var e = event.element();
if (e.match('.activator')) {
doSomeStuffWith(e);
} else if (e.match('.activator *')) {
doSomeStuffWith(e.up('.activator');
}
});
So if I click the .activator or any of its child elements I want to call a function on the .activator, I'm just wondering if there isn't some way of combining the two if-clauses. Something like if (e.match('.class, .class *') { doStuff(e.upOrSelf('activator')); }
I guess I could extend the Element with an upOrSelf method. But I would prefer not to do any non-standard customizations if possible.