diff options
| author | Heinrich Fenkart <[email protected]> | 2014-09-25 02:08:30 +0200 |
|---|---|---|
| committer | Heinrich Fenkart <[email protected]> | 2014-09-25 02:08:30 +0200 |
| commit | 61a4fee626f5c10eb56149d0d8abb093c9fbbf98 (patch) | |
| tree | 4b848f10c148140ef46908d23564a25c4d2ece9f /js/tests | |
| parent | e70fc61eff8f4e08ccf1728ecbce7e32465cdd25 (diff) | |
| parent | 24ae068f21bd619235dfed5b9218b5b83b815160 (diff) | |
| download | bootstrap-61a4fee626f5c10eb56149d0d8abb093c9fbbf98.tar.xz bootstrap-61a4fee626f5c10eb56149d0d8abb093c9fbbf98.zip | |
Merge pull request #14599 from twbs/tooltip-outerDims-only-when-body
Tooltip: Rely on `getBoundingClientRect` for `width` and `height`
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/tooltip.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 529b6f5cf..fd02a5e7f 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -919,4 +919,42 @@ $(function () { .bootstrapTooltip('show') }) + test('should correctly position tooltips on transformed elements', function () { + var styleProps = document.documentElement.style + if (!('transform' in styleProps) && !('webkitTransform' in styleProps) && !('msTransform' in styleProps)) { + expect(0) + return + } + + stop() + + var styles = '<style>' + + '#qunit-fixture { top: 0; left: 0; }' + + '.tooltip, .tooltip *, .tooltip *:before, .tooltip *:after { box-sizing: border-box; }' + + '.tooltip { position: absolute; }' + + '.tooltip .tooltip-inner { width: 24px; height: 24px; font-family: Helvetica; }' + + '#target { position: absolute; top: 100px; left: 50px; width: 100px; height: 200px; -webkit-transform: rotate(270deg); -ms-transform: rotate(270deg); transform: rotate(270deg); }' + + '</style>' + var $styles = $(styles).appendTo('head') + + var $element = $('<div id="target" title="1"/>').appendTo('#qunit-fixture') + + $element + .on('shown.bs.tooltip', function () { + var offset = $('.tooltip').offset() + $styles.remove() + ok(Math.abs(offset.left - 88) <= 1, 'tooltip has correct horizontal location') + ok(Math.abs(offset.top - 126) <= 1, 'tooltip has correct vertical location') + $element.bootstrapTooltip('hide') + start() + }) + .bootstrapTooltip({ + container: 'body', + placement: 'top', + trigger: 'manual' + }) + + $element.bootstrapTooltip('show') + }) + }) |
