bug fix: clear previous highlights

This commit is contained in:
Artur Adib 2012-09-26 14:09:55 -04:00
parent 6022476f03
commit 73b96e0e58

View File

@ -2365,6 +2365,18 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
return ret;
};
this.clearMatches = function textLayerBuilder_clearMatches() {
var textDivs = this.textDivs;
// Clear all previous highlights
textDivs.forEach(function(div) {
var spans = div.querySelectorAll('span');
for (var i = 0, ii = spans.length; i < ii; i++) {
spans[i].className = '';
}
});
}
this.renderMatches = function textLayerBuilder_renderMatches(matches) {
var bidiTexts = this.textContent.bidiTexts;
var textDivs = this.textDivs;
@ -2372,6 +2384,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv, pageIdx) {
var isSelectedPage = this.pageIdx === PDFFindController.selected.pageIdx;
var selectedMatchIdx = PDFFindController.selected.matchIdx;
this.clearMatches();
var infty = {
divIdx: -1,
offset: undefined