Skip to content

Commit dd8e04c

Browse files
justsmllord
authored andcommitted
Cleans HTML before setting document.title (#946)
Fixes slatedocs#945
1 parent 55cbe85 commit dd8e04c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/javascripts/app/_toc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
;(function () {
44
'use strict';
55

6+
var htmlPattern = /<[^>]*>/g;
67
var loaded = false;
78

89
var debounce = function(func, waitTime) {
@@ -66,6 +67,7 @@
6667
}
6768

6869
var $best = $toc.find("[href='" + best + "']").first();
70+
var joinedTitle = $best.data("title") + " – " + originalTitle;
6971
if (!$best.hasClass("active")) {
7072
// .active is applied to the ToC link we're currently on, and its parent <ul>s selected by tocListSelector
7173
// .active-expanded is applied to the ToC links that are parents of this one
@@ -77,7 +79,7 @@
7779
$toc.find(tocListSelector).filter(":not(.active)").slideUp(150);
7880
$toc.find(tocListSelector).filter(".active").slideDown(150);
7981
// TODO remove classnames
80-
document.title = $best.data("title") + " – " + originalTitle;
82+
document.title = joinedTitle.replace(htmlPattern, '');
8183
}
8284
};
8385

0 commit comments

Comments
 (0)