diff options
| author | Rohit Sharma <[email protected]> | 2021-02-10 00:46:13 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-09 21:16:13 +0200 |
| commit | f7088e5d28d019f9876b71333185120b811ecb08 (patch) | |
| tree | c17979945db9035e6f466541abf11712605ca549 /js/src | |
| parent | 29e0c9dfa1c4324e4e2a8cf0b66e27b9e72f09a5 (diff) | |
| download | bootstrap-f7088e5d28d019f9876b71333185120b811ecb08.tar.xz bootstrap-f7088e5d28d019f9876b71333185120b811ecb08.zip | |
Add function type for `popperConfig` option (#32882)
* Add function type for `popperConfig` option
* Update .bundlewatch.config.json
* copy edits
Co-authored-by: XhmikosR <[email protected]>
Co-authored-by: Mark Otto <[email protected]>
Diffstat (limited to 'js/src')
| -rw-r--r-- | js/src/dropdown.js | 10 | ||||
| -rw-r--r-- | js/src/tooltip.js | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/js/src/dropdown.js b/js/src/dropdown.js index 878a5a9a2..7221debfc 100644 --- a/js/src/dropdown.js +++ b/js/src/dropdown.js @@ -86,7 +86,7 @@ const DefaultType = { boundary: '(string|element)', reference: '(string|element|object)', display: 'string', - popperConfig: '(null|object)' + popperConfig: '(null|object|function)' } /** @@ -322,7 +322,7 @@ class Dropdown extends BaseComponent { } _getPopperConfig() { - const popperConfig = { + const defaultBsPopperConfig = { placement: this._getPlacement(), modifiers: [{ name: 'preventOverflow', @@ -341,15 +341,15 @@ class Dropdown extends BaseComponent { // Disable Popper if we have a static display if (this._config.display === 'static') { - popperConfig.modifiers = [{ + defaultBsPopperConfig.modifiers = [{ name: 'applyStyles', enabled: false }] } return { - ...popperConfig, - ...this._config.popperConfig + ...defaultBsPopperConfig, + ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) } } diff --git a/js/src/tooltip.js b/js/src/tooltip.js index 11209625c..42da4c938 100644 --- a/js/src/tooltip.js +++ b/js/src/tooltip.js @@ -58,7 +58,7 @@ const DefaultType = { sanitize: 'boolean', sanitizeFn: '(null|function)', allowList: 'object', - popperConfig: '(null|object)' + popperConfig: '(null|object|function)' } const AttachmentMap = { @@ -490,7 +490,7 @@ class Tooltip extends BaseComponent { } _getPopperConfig(attachment) { - const defaultBsConfig = { + const defaultBsPopperConfig = { placement: attachment, modifiers: [ { @@ -533,8 +533,8 @@ class Tooltip extends BaseComponent { } return { - ...defaultBsConfig, - ...this.config.popperConfig + ...defaultBsPopperConfig, + ...(typeof this.config.popperConfig === 'function' ? this.config.popperConfig(defaultBsPopperConfig) : this.config.popperConfig) } } |
