From 122c05dbd87d9708086da4d097f7e715233f3b2c Mon Sep 17 00:00:00 2001 From: "j.corns" Date: Wed, 14 May 2014 10:36:32 -0700 Subject: [PATCH] Add tooltip self-reference to address #12320 primarily adds a data- attribute to the tooltip (and thus, the popover) to create a self-reference. --- js/tests/unit/popover.js | 10 ++++++++++ js/tests/unit/tooltip.js | 11 +++++++++++ js/tooltip.js | 1 + 3 files changed, 22 insertions(+) diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js index 1a095564be..b28e1f3a7f 100644 --- a/js/tests/unit/popover.js +++ b/js/tests/unit/popover.js @@ -46,6 +46,16 @@ $(function () { ok(!!popover.data('bs.popover'), 'popover instance exists') }) + test('should store popover trigger in popover instance data object', function () { + $.support.transition = false + var popover = $('@ResentedHook') + .appendTo('#qunit-fixture') + .bootstrapPopover() + popover.bootstrapPopover('show') + ok(!!$('.popover').data('bs.popover'), 'popover trigger stored in instance data') + $('#qunit-fixture').empty() + }) + test('should get title and content from options', function () { $.support.transition = false var popover = $('@fat') diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index e579a9ef7f..6c24111b8e 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -295,6 +295,17 @@ $(function () { ok($('.tooltip').is('.fade.in'), 'tooltip should be toggled in') }) + test('should hide shown tooltip when toggle is called on tooltip', function () { + var tooltip = $('@ResentedHook') + .appendTo('#qunit-fixture') + .bootstrapTooltip({trigger: 'manual'}) + .bootstrapTooltip('toggle') + $('.tooltip', '#qunit-fixture').bootstrapTooltip('toggle') + ok($('.tooltip').not('.fade.in'), 'tooltip should be toggled out') + tooltip.bootstrapTooltip('hide') + $('#qunit-fixture').empty() + }) + test('should place tooltips inside the body', function () { var tooltip = $('') .appendTo('#qunit-fixture') diff --git a/js/tooltip.js b/js/tooltip.js index d985f96e34..076f2fa1cc 100644 --- a/js/tooltip.js +++ b/js/tooltip.js @@ -166,6 +166,7 @@ .detach() .css({ top: 0, left: 0, display: 'block' }) .addClass(placement) + .data('bs.' + this.type, this) this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)