Skip to content

[Popover] data-bs-content="true"/"false" auto-converted to boolean causes TypeError, but "true"/"false" are valid string content. #41925

@Andyz0103

Description

@Andyz0103

Prerequisites

Describe the issue

When using data-bs-content="true" (or "false") on an element with data-bs-toggle="popover", Bootstrap internally converts the string "true" to the boolean true, causing _typeCheckConfig to throw:

TypeError: POPOVER: Option "content" provided type "boolean" but expected type "(null|string|element|function)".

This prevents users from displaying the literal string "true" or "false" — a common and valid use case (e.g., showing boolean-like values in tables, configs, JSON previews).

Reduced test cases

  1. Add this HTML:
    <button type="button" class="btn btn-secondary" data-bs-toggle="popover" data-bs-content="true"> Show "true" </button>

  2. Initialize popovers (e.g., via new bootstrap.Popover() or auto-init via data-bs-toggle).

  3. Observe console error:
    TypeError: POPOVER: Option "content" provided type "boolean" but expected type "(null|string|element|function)".

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?

v5.2.1

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