Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remake and add isHTML check to popover as well

  • Loading branch information...
commit 83febb3452ecd81241ddc004509ec64de8b13a92 1 parent 4bd6118
@fat fat authored
View
BIN  docs/assets/bootstrap.zip
Binary file not shown
View
4 docs/assets/js/bootstrap-popover.js
@@ -38,8 +38,8 @@
, title = this.getTitle()
, content = this.getContent()
- $tip.find('.popover-title').html(title)
- $tip.find('.popover-content > *').html(content)
+ $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
+ $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
$tip.removeClass('fade top bottom left right in')
}
View
13 docs/assets/js/bootstrap-tooltip.js
@@ -155,9 +155,20 @@
}
}
+ , isHTML: function( text ) {
+ // html string detection logic adapted from jQuery
+ return typeof text != 'string'
+ || ( text.charAt(0) === "<"
+ && text.charAt( text.length - 1 ) === ">"
+ && text.length >= 3
+ ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
+ }
+
, setContent: function () {
var $tip = this.tip()
- $tip.find('.tooltip-inner').html(this.getTitle())
+ , title = this.getTitle()
+
+ $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
View
4 js/bootstrap-popover.js
@@ -38,8 +38,8 @@
, title = this.getTitle()
, content = this.getContent()
- $tip.find('.popover-title').html(title)
- $tip.find('.popover-content > *').html(content)
+ $tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
+ $tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
$tip.removeClass('fade top bottom left right in')
}
View
3  js/bootstrap-tooltip.js
@@ -167,9 +167,8 @@
, setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
- , isHTML = this.isHTML(title)
- $tip.find('.tooltip-inner')[isHTML ? 'html' : 'text'](title)
+ $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}

4 comments on commit 83febb3

@David-Mulder

This commit seems to have broken the popover functionality giving a
Uncaught TypeError: Object [object Object] has no method 'isHTML'
on
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
where "this" is the window scope.

@fat
Owner

why would your setContent have the window's scope?

@David-Mulder

Not sure, I submitted the issue+comment on behalf of a college which encountered this problem so I am not even entirely sure of the context and he isn't used to open source projects (till half a year ago he worked in a asp.net environment) so I reverted his popover.js to a pre this commit version which solved the issue and quickly wanted to dump a message here that I had observed this problem. Possibly I will have some time Friday afternoon to look into this for a bit longer (it could be that he had a version mismatch of an older bootstrap version with the newest version of this file)

@fat
Owner

hm... ok let me know, thanks!

Please sign in to comment.
Something went wrong with that request. Please try again.