Skip to content

Commit

Permalink
Cleans HTML before setting document.title (#946)
Browse files Browse the repository at this point in the history
  • Loading branch information
justsml authored and lord committed Jan 28, 2018
1 parent 55cbe85 commit dd8e04c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/javascripts/app/_toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
;(function () {
'use strict';

var htmlPattern = /<[^>]*>/g;
var loaded = false;

var debounce = function(func, waitTime) {
Expand Down Expand Up @@ -66,6 +67,7 @@
}

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

Expand Down

0 comments on commit dd8e04c

Please sign in to comment.