You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add detailed explanation of the JS components configuration merging process (#37303)
* doc: add detailed explanation of the components config process & fix popover/tooltip docs
* Update site/layouts/partials/js-data-attributes.md
---------
Co-authored-by: Mark Otto <markd.otto@gmail.com>
Copy file name to clipboardexpand all lines: site/content/docs/5.3/components/popovers.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
187
187
|`animation`| boolean |`true`| Apply a CSS fade transition to the popover. |
188
188
|`boundary`| string, element |`'clippingParents'`| Overflow constraint boundary of the popover (applies only to Popper's preventOverflow modifier). By default, it's `'clippingParents'` and can accept an HTMLElement reference (via JavaScript only). For more information refer to Popper's [detectOverflow docs](https://popper.js.org/docs/v2/utils/detect-overflow/#boundary). |
189
189
|`container`| string, element, false |`false`| Appends the popover to a specific element. Example: `container: 'body'`. This option is particularly useful in that it allows you to position the popover in the flow of the document near the triggering element - which will prevent the popover from floating away from the triggering element during a window resize. |
190
-
|`content`| string, element, function |`''`|Default content value if `data-bs-content` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
190
+
|`content`| string, element, function |`''`|The popover's text content. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
191
191
|`customClass`| string, function |`''`| Add classes to the popover when it is shown. Note that these classes will be added in addition to any classes specified in the template. To add multiple classes, separate them with spaces: `'class-1 class-2'`. You can also pass a function that should return a single string containing additional class names. |
192
192
|`delay`| number, object |`0`| Delay showing and hiding the popover (ms)—doesn't apply to manual trigger type. If a number is supplied, delay is applied to both hide/show. Object structure is: `delay: { "show": 500, "hide": 100 }`. |
193
193
|`fallbackPlacements`| string, array |`['top', 'right', 'bottom', 'left']`| Define fallback placements by providing a list of placements in array (in order of preference). For more information refer to Popper's [behavior docs](https://popper.js.org/docs/v2/modifiers/flip/#fallbackplacements). |
@@ -199,7 +199,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
199
199
|`sanitizeFn`| null, function |`null`| Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. |
200
200
|`selector`| string, false |`false`| If a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to also apply popovers to dynamically added DOM elements (`jQuery.on` support). See [this issue]({{< param repo >}}/issues/4215) and [an informative example](https://codepen.io/Johann-S/pen/djJYPb). **Note**: `title` attribute must not be used as a selector. |
201
201
|`template`| string |`'<div class="popover" role="popover"><div class="popover-arrow"></div><div class="popover-inner"></div></div>'`| Base HTML to use when creating the popover. The popover's `title` will be injected into the `.popover-inner`. `.popover-arrow` will become the popover's arrow. The outermost wrapper element should have the `.popover` class and `role="popover"`. |
202
-
|`title`| string, element, function |`''`|Default title value if `title` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
202
+
|`title`| string, element, function |`''`|The popover title. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
203
203
|`trigger`| string |`'hover focus'`| How popover is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. `'manual'` indicates that the popover will be triggered programmatically via the `.popover('show')`, `.popover('hide')` and `.popover('toggle')` methods; this value cannot be combined with any other trigger. `'hover'` on its own will result in popovers that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present. |
Copy file name to clipboardexpand all lines: site/content/docs/5.3/components/tooltips.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -214,7 +214,7 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
214
214
|`sanitizeFn`| null, function |`null`| Here you can supply your own sanitize function. This can be useful if you prefer to use a dedicated library to perform sanitization. |
215
215
|`selector`| string, false |`false`| If a selector is provided, tooltip objects will be delegated to the specified targets. In practice, this is used to also apply tooltips to dynamically added DOM elements (`jQuery.on` support). See [this issue]({{< param repo >}}/issues/4215) and [an informative example](https://codepen.io/Johann-S/pen/djJYPb). **Note**: `title` attribute must not be used as a selector. |
216
216
|`template`| string |`'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'`| Base HTML to use when creating the tooltip. The tooltip's `title` will be injected into the `.tooltip-inner`. `.tooltip-arrow` will become the tooltip's arrow. The outermost wrapper element should have the `.tooltip` class and `role="tooltip"`. |
217
-
|`title`| string, element, function |`''`|Default title value if `title` attribute isn't present. If a function is given, it will be called with its `this` reference set to the element that the tooltip is attached to. |
217
+
|`title`| string, element, function |`''`|The tooltip title. If a function is given, it will be called with its `this` reference set to the element that the popover is attached to. |
218
218
|`trigger`| string |`'hover focus'`| How tooltip is triggered: click, hover, focus, manual. You may pass multiple triggers; separate them with a space. `'manual'` indicates that the tooltip will be triggered programmatically via the `.tooltip('show')`, `.tooltip('hide')` and `.tooltip('toggle')` methods; this value cannot be combined with any other trigger. `'hover'` on its own will result in tooltips that cannot be triggered via the keyboard, and should only be used if alternative methods for conveying the same information for keyboard users is present. |
As options can be passed via data attributes or JavaScript, you can append an option name to `data-bs-`, as in `data-bs-animation="{value}"`. Make sure to change the case type of the option name from "_camelCase_" to "_kebab-case_" when passing the options via data attributes. For example, use `data-bs-custom-class="beautifier"` instead of `data-bs-customClass="beautifier"`.
2
2
3
3
As of Bootstrap 5.2.0, all components support an **experimental** reserved data attribute `data-bs-config` that can house simple component configuration as a JSON string. When an element has `data-bs-config='{"delay":0, "title":123}'` and `data-bs-title="456"` attributes, the final `title` value will be `456` and the separate data attributes will override values given on `data-bs-config`. In addition, existing data attributes are able to house JSON values like `data-bs-delay='{"show":0,"hide":150}'`.
4
+
5
+
The final configuration object is the merged result of `data-bs-config`, `data-bs-`, and `js object` where the latest given key-value overrides the others.
0 commit comments