aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorfat <[email protected]>2013-07-17 23:25:26 -0700
committerfat <[email protected]>2013-07-17 23:25:26 -0700
commit8cf04911db36b1ad5f4a98db51b44050c78df18a (patch)
tree2ed5d6e7d610b21b6d6464ac8391a35038a3407e /js
parent451acb42dbf71d2902dbc9f2e2ab45294401e487 (diff)
downloadbootstrap-8cf04911db36b1ad5f4a98db51b44050c78df18a.tar.xz
bootstrap-8cf04911db36b1ad5f4a98db51b44050c78df18a.zip
fixes #7776
Diffstat (limited to 'js')
-rw-r--r--js/popover.js10
-rw-r--r--js/tests/unit/popover.js20
-rw-r--r--js/tests/unit/tooltip.js2
3 files changed, 27 insertions, 5 deletions
diff --git a/js/popover.js b/js/popover.js
index e58e24908..482985b63 100644
--- a/js/popover.js
+++ b/js/popover.js
@@ -64,11 +64,13 @@
}
Popover.prototype.getContent = function () {
- var content = typeof this.options.content == 'function' ?
- this.options.content.call(this.$element[0]) :
- this.options.content
+ var $e = this.$element
+ var o = this.options
- return content || this.$element.attr('data-content')
+ return $e.attr('data-content')
+ || (typeof o.content == 'function' ?
+ o.content.call($e[0]) :
+ o.content)
}
Popover.prototype.tip = function () {
diff --git a/js/tests/unit/popover.js b/js/tests/unit/popover.js
index fb0017567..767d79864 100644
--- a/js/tests/unit/popover.js
+++ b/js/tests/unit/popover.js
@@ -77,6 +77,26 @@ $(function () {
$('#qunit-fixture').empty()
})
+
+ test("should get title and content from attributes #2", function () {
+ $.support.transition = false
+ var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
+ .appendTo('#qunit-fixture')
+ .popover({
+ title: 'ignored title option',
+ content: 'ignored content option'
+ })
+ .popover('show')
+
+ ok($('.popover').length, 'popover was inserted')
+ equals($('.popover .popover-title').text(), '@mdo', 'title correctly inserted')
+ equals($('.popover .popover-content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
+
+ popover.popover('hide')
+ ok(!$('.popover').length, 'popover was removed')
+ $('#qunit-fixture').empty()
+ })
+
test("should respect custom classes", function() {
$.support.transition = false
var popover = $('<a href="#">@fat</a>')
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js
index b2b004d6e..610505588 100644
--- a/js/tests/unit/tooltip.js
+++ b/js/tests/unit/tooltip.js
@@ -296,7 +296,7 @@ $(function () {
$("head").append('<style> .tooltip.right { white-space: nowrap; } .tooltip.right .tooltip-inner { max-width: none; } </style>')
var container = $("<div />").appendTo("body")
- , target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line">To my right</a>')
+ , target = $('<a href="#" rel="tooltip" title="very very very very very very very very long tooltip in one line"></a>')
.appendTo(container)
.tooltip({placement: 'right'})
.tooltip('show')