Skip to content

fix(tooltip): coerce boolean title/content to string#42365

Closed
stafferin wants to merge 1 commit intotwbs:mainfrom
stafferin:fix-popover-boolean-content
Closed

fix(tooltip): coerce boolean title/content to string#42365
stafferin wants to merge 1 commit intotwbs:mainfrom
stafferin:fix-popover-boolean-content

Conversation

@stafferin
Copy link
Copy Markdown

Summary

Fixes #41925.

data-bs-content=\"true\" (or \"false\") on a popover/tooltip throws:

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

This is because Manipulator.normalizeData converts the strings \"true\"/\"false\" to actual booleans before the config type check runs. _configAfterMerge already coerces numeric title/content back to strings — this PR extends that same pattern to booleans, so the literal strings \"true\"/\"false\" render as expected.

Test plan

  • Added unit test in `tooltip.spec.js` mirroring the existing "convert title and content to string if numbers" test, but for booleans.
  • Added unit test in `popover.spec.js` covering the original repro: `data-bs-content="true"` produces `_config.content === 'true'`.
  • CI runs the full karma suite.

Data attributes parsed via Manipulator.normalizeData convert "true"/"false"
to actual booleans, which then fail the (null|string|element|function)
type check for popover/tooltip content. Mirror the existing number → string
coercion in _configAfterMerge so that data-bs-content="true" renders the
literal string "true".

Closes twbs#41925
@stafferin stafferin requested a review from a team as a code owner April 27, 2026 02:28
@XhmikosR
Copy link
Copy Markdown
Member

Closing as duplicate of #42155.

@XhmikosR XhmikosR closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants