How about this?

$.fn.owns = function(selector) {
        var owns = [];
        this.filter('[aria-owns]').each(function(){
                
owns.push('#'+this.getAttribute('aria-owns').replace(/\s+/g,',#'));
        });
        return this.find('*').add(owns.join()).filter(selector);
};

Real children get precedence over the aria-owns stepchildren with this
approach. It seems to work for your situation but I don't know if
that's the right interpretation. Also, the selector is limited to the
"simple selector" used by filter(), basically that means no descendant
or child selectors can be in it.

Reply via email to