Bug Tracker

Opened 7 years ago

Closed 7 years ago

#10696 closed enhancement (invalid)

Proposed enhancement of :not selector

Reported by: sneethling@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7
Keywords: Cc:
Blocked by: Blocking:

Description

If I have HTML such as:

<details>

<summary>Some text content</summary> <p>Some text content</p> <p>Some text content</p>

</details>

And I use the :not selector as follows:

$("details :not(summary)");

I get the expected result where the result contains the two paragraphs. If however I change the summary line as follows:

<summary>Some <abbr title="some explaination">text</abbr> content</summary>

The result now includes the two paragraphs but also the abbr. The expected result would be that just the two paragraphs should be in the result.

Reading the API: "The supplied selector is tested against each element; the elements that don't match the selector will be included in the result." - This explains why the above is happening.

However, if the content you wish to exclude is dynamically generated, you will not always know what other tags might be added inside the summary element for example therefore, making something like:

$(".details :not(.summary, abbr)");

not really an option. I therefore propose that the .not() and/or :not() functions have a boolean that maps to includeChildElements. If this is true, then exclude the selector and all of it's contained child elements.

More can be seen here: http://jsfiddle.net/MHQyg/2/

Change History (1)

comment:1 Changed 7 years ago by dmethvin

Resolution: invalid
Status: newclosed

Your understanding of :not() is wrong, which is why I asked you to go to the forum (not the bug tracker). #jquery-dev isn't really set up for tutorials. I looked at your example about 5 minutes after you left and tried to find you in #jquery but it seems you were a hit-and-runner.

http://jsfiddle.net/dmethvin/MHQyg/3/

Honestly, if you need more help ask on the forum, because the bug tracker isn't set up for tutorials either.

Note: See TracTickets for help on using tickets.