Skip to main content

Bug Tracker

Side navigation

#9515 closed feature (invalid)

Opened June 04, 2011 09:14AM UTC

Closed June 04, 2011 05:26PM UTC

el(.comma, .separated, .list):pseudo

Reported by: OP Owned by: OP
Priority: low Milestone: 1.next
Component: selector Version: 1.6.1
Keywords: Cc:
Blocked by: Blocking:
Description

Assuming this is the css code

div.class1.style, div.class2.style { background: red; }
*.style { background: blue; }

I was surprised that this would work (the comma separated list in the parenthesis)

$("div(.class1, .class2):parent").each(function(){
	$(this).addClass('style');
});

(basically selects all non empty div.classN elements)

But, this just doesn't do anything

$("div(.class1, .class2)").each(function(){
	$(this).addClass('style');
});

I am curious at to why?

Attachments (0)
Change History (5)

Changed June 04, 2011 12:59PM UTC by rwaldron comment:1

component: unfiledselector
owner: → OP
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, I've created this boilerplate: http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.

Changed June 04, 2011 03:16PM UTC by OP comment:2

status: pendingnew

http://jsfiddle.net/geVsk/

Oh it seems that in the first case (.class1, .class2) jQuery just ignores the stuff parenthesis and in the second it ignores everything... I've just tested it on my PC too and works the same... I guess I didn't test it thoroughly the first time...

So maybe I could rephrase the original question to:

Could we add the parenthesis sel(sel, sel, sel)sel as a selector meaning select all in the comma separated list?

Changed June 04, 2011 04:17PM UTC by ajpiano comment:3

It's unclear to me what you intend for this "selector" to do? There are a number of pseudoselectors that accept a comma-delimited list of selectors - :not(), :has(), etc - in addition to jQuery() itself. The suggestion you've made here, however, is quite vague - does it work like .find()? .filter()? This may be a case of the combination of misunderstanding how selectors (including the :parent pseudo) are intended to work (more or less like CSS - where there is no "parenthesis selector") - and the library handling completely unexpected input in an unexpected way. Turning that into a selector-based alias for filter as a feature doesn't seem like a wise idea to me.

I'd suggest instead just doing $("div").filter(".class1, .class2").whatever();

Thanks for your time and interest in helping out the jQuery project!

Changed June 04, 2011 05:19PM UTC by OP comment:4

Yeah I meant () (I dubbed it "parenthesis selector" :P ) to be as a selector alias for filter() but if you don't think its a good idea I have no problems with it not happening

Changed June 04, 2011 05:26PM UTC by dmethvin comment:5

priority: undecidedlow
resolution: → invalid
status: newclosed

We definitely want to stick with standard CSS selectors so that jQuery can take advantage of the native querySelectorAll methods. I really do wish CSS4 adds some sort of parenthesized operator as well though, it would be mighty handy at times.