Skip to content

Expression to negate has()? #62

@Madd0g

Description

@Madd0g

Hey, I'm trying to filter objects that have one property, but don't have another. Is there a way to do that? Given this structure:

{
    people: [
        {
            name: "Betty",
            friend: { name: "Robert" }
        },
        {
            name: "Victoria",
            friend: { 
                name: "Chris", id: 1,
                people: [
                    {
                        friend: {
                            name: "Jon"     
                        }
                    }
                ]
            }
        },
    ]
}

I use this selector: object:has(.friend > .name) but I also want to include a condition - to get those friends that don't have an id, something like: object:has(.friend > .name):hasnot(.friend > .id) (to get objects that contain Robert and Jon, but not Chris)

Is this possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions