Skip to content

find() with a :not selector does not have "scoped" behavior #5191

@Pointy

Description

@Pointy

Description

A .find() call like $(x).find(".foo button") will only find button elements that have a parent with class "foo" somewhere in the DOM subtree under element x. That is the jQuery intention.

However, a .find() call like $(x).find(":not(.foo button)") will find all elements that are not a button descending from an element with class "foo". However, that descendant test is not scoped to the subtree under element x. If any element from x up to the root of the DOM has class "foo", buttons will be excluded from the result.

This may be intentional or preserved for legacy reasons. I have not personally suffered from this, the bug is mostly to have something to reference.

Link to test case

https://codepen.io/Pointy/pen/OJwWyMb?editors=1111

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions