2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-17 19:21:23 +03:00

Add function type for popperConfig option (#32882)

* Add function type for `popperConfig` option

* Update .bundlewatch.config.json

* copy edits

Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Co-authored-by: Mark Otto <markdotto@gmail.com>
This commit is contained in:
Rohit Sharma
2021-02-10 00:46:13 +05:30
committed by GitHub
parent 29e0c9dfa1
commit f7088e5d28
9 changed files with 99 additions and 16 deletions
+17 -2
View File
@@ -993,13 +993,28 @@ Options can be passed via data attributes or JavaScript. For data attributes, ap
</tr>
<tr>
<td><code>popperConfig</code></td>
<td>null | object</td>
<td>null | object | function</td>
<td><code>null</code></td>
<td>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a></td>
<td>
<p>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a>.</p>
<p>When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.</p>
</td>
</tr>
</tbody>
</table>
#### Using function with `popperConfig`
```js
var dropdown = new bootstrap.Dropdown(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
```
### Methods
<table class="table">
+17 -2
View File
@@ -279,9 +279,12 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
</tr>
<tr>
<td><code>popperConfig</code></td>
<td>null | object</td>
<td>null | object | function</td>
<td><code>null</code></td>
<td>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a></td>
<td>
<p>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a>.</p>
<p>When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.</p>
</td>
</tr>
</tbody>
</table>
@@ -292,6 +295,18 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
{{< /callout >}}
#### Using function with `popperConfig`
```js
var popover = new bootstrap.Popover(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
```
### Methods
{{< callout danger >}}
+17 -2
View File
@@ -304,9 +304,12 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
</tr>
<tr>
<td><code>popperConfig</code></td>
<td>null | object</td>
<td>null | object | function</td>
<td><code>null</code></td>
<td>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a></td>
<td>
<p>To change Bootstrap's default Popper config, see <a href="https://popper.js.org/docs/v2/constructors/#options">Popper's configuration</a>.</p>
<p>When a function is used to create the Popper configuration, it's called with an object that contains the Bootstrap's default Popper configuration. It helps you use and merge the default with your own configuration. The function must return a configuration object for Popper.</p>
</td>
</tr>
</tbody>
</table>
@@ -317,6 +320,18 @@ Note that for security reasons the `sanitize`, `sanitizeFn`, and `allowList` opt
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
{{< /callout >}}
#### Using function with `popperConfig`
```js
var tooltip = new bootstrap.Tooltip(element, {
popperConfig: function (defaultBsPopperConfig) {
// var newPopperConfig = {...}
// use defaultBsPopperConfig if needed...
// return newPopperConfig
}
})
```
### Methods
{{< callout danger >}}