Home > Blockchain >  What is the difference between Bootstrap data-toggle vs data-bs-toggle attributes?
What is the difference between Bootstrap data-toggle vs data-bs-toggle attributes?

Time:10-14

Context

I am using a Bootstrap theme, and now I noticed, when the theme updated to Bootstrap 5 all data-toggle attributes were replaced with data-bs-toggle (except one, which element still works btw)

Question

What is the difference between Bootstrap data-toggle vs data-bs-toggle attributes?

CodePudding user response:

This comes fro PR 31827 and commit 418f17e (Nov. 2020, bootstrap v5.0.0-beta1)

It fixes issue 29479 "Add a namespace for data-* attribute?"

As explained in "What’s New in Bootstrap 5 / Change in data attributes" from Shahed Nasser:

Bootstrap 5 has changed the naming of the data attributes that are generally used by its components that use JavaScript as part of their functionality.

Previously, most components that relied on some JavaScript functionalities would have data attributes starting with data-.

In Bootstrap 5, data attributes for these components now start with data-bs to easily namespace Bootstrap attributes.

Commit b38110a concurs:

Data attributes for all JavaScript plugins are now namespaced to help distinguish Bootstrap functionality from third parties and your own code.
For example, we use data-bs-toggle instead of data-toggle.

  • Related