Skip to content

data-bs-target doesn't support complex css selector with id #40997

Open
@chatelain

Description

Prerequisites

Describe the issue

The data-bs-target css selector doesn't works with complex selector like "#myDiv:not(.show)".
I have checked it with the dropdown and collapse components.
It works in version 5.2, but not 5.3.3

This is useful if you want a button to open a collapse, without being able to close it when you click again.

Reduced test cases

<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#myDiv:not(.show)">Open</button>
<div id="myDiv" class="collapse">Hidden message</div>

If you rename the div id to <div id="myDiv:not(.show)"></div> (what is a wrong thing to do), it toggle the collapse again.

bootstrap_example.txt

What operating system(s) are you seeing the problem on?

Windows

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

5.3.3

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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