diff options
author | Rohit Sharma <rohit2sharma95@gmail.com> | 2021-05-18 09:02:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-18 09:02:39 +0300 |
commit | 153cf3a235ec7fd86c09cbe5f31d7eebd0aab661 (patch) | |
tree | 30c620c608a4df4eb63cf2d7dcbdc1821b1986d5 /js/src/popover.js | |
parent | 0b2d20b975af55c3df8297d022e8d75b32e303ad (diff) |
Don't add empty content holder when there is no content available (#33982)
* Remove content holder when there is no content
* Add tests to check the removal of header/content
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
Diffstat (limited to 'js/src/popover.js')
-rw-r--r-- | js/src/popover.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/js/src/popover.js b/js/src/popover.js index b399851248..6ab31d6e49 100644 --- a/js/src/popover.js +++ b/js/src/popover.js @@ -30,7 +30,7 @@ const Default = { content: '', template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + - '<h3 class="popover-header"></h3>' + + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' } @@ -90,6 +90,24 @@ class Popover extends Tooltip { return this.getTitle() || this._getContent() } + getTipElement() { + if (this.tip) { + return this.tip + } + + this.tip = super.getTipElement() + + if (!this.getTitle()) { + this.tip.removeChild(SelectorEngine.findOne(SELECTOR_TITLE, this.tip)) + } + + if (!this._getContent()) { + this.tip.removeChild(SelectorEngine.findOne(SELECTOR_CONTENT, this.tip)) + } + + return this.tip + } + setContent() { const tip = this.getTipElement() |