aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Rebert <[email protected]>2014-08-01 12:10:46 -0700
committerChris Rebert <[email protected]>2014-08-01 12:10:46 -0700
commit948a74662f655cb52b2867d1b2c898cdb7712c41 (patch)
treef2ae893297fc0e7cf9afb24e2e1106e00d69b966
parentde1d8c36ada0a36691c1c9120755455f3bbcd2ea (diff)
parent08393bf68a568a383688bf9d7ab90b824f6a5b34 (diff)
downloadbootstrap-948a74662f655cb52b2867d1b2c898cdb7712c41.tar.xz
bootstrap-948a74662f655cb52b2867d1b2c898cdb7712c41.zip
Merge pull request #14299 from twbs/fix-14076
Add unit test for tooltips on SVG elements
-rw-r--r--js/tests/unit/tooltip.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index fb1940b2d..7896c2c96 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -739,4 +739,40 @@ $(function () {
$tooltip.trigger('mouseenter')
})
+ test('should correctly position tooltips on SVG elements', function () {
+ if (!window.SVGElement) {
+ // Skip IE8 since it doesn't support SVG
+ expect(0)
+ return
+ }
+
+ stop()
+
+ var styles = '<style>'
+ + '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }'
+ + '.tooltip { position: absolute; }'
+ + '.tooltip .tooltip-inner { width: 24px; height: 24px; font-family: Helvetica; }'
+ + '</style>'
+ var $styles = $(styles).appendTo('head')
+
+ $('#qunit-fixture').append(
+ '<div style="position: fixed; top: 0; left: 0;">'
+ + ' <svg width="200" height="200">'
+ + ' <circle cx="100" cy="100" r="10" title="m" id="theCircle" />'
+ + ' </svg>'
+ + '</div>')
+ var $circle = $('#theCircle')
+
+ $circle
+ .on('shown.bs.tooltip', function () {
+ var offset = $('.tooltip').offset()
+ $styles.remove()
+ ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location')
+ start()
+ })
+ .bootstrapTooltip({ container: 'body', placement: 'top', trigger: 'manual' })
+
+ $circle.bootstrapTooltip('show')
+ })
+
})