diff --git a/public/res/extensions/partialRendering.js b/public/res/extensions/partialRendering.js index 26453499..56efedec 100644 --- a/public/res/extensions/partialRendering.js +++ b/public/res/extensions/partialRendering.js @@ -104,10 +104,14 @@ define([ } var footnoteMap = {}; + var footnoteFragment = document.createDocumentFragment(); // Store one footnote elt in the footnote map function storeFootnote(footnoteElt) { var id = footnoteElt.id.substring(3); + var oldFootnote = footnoteMap[id]; + oldFootnote && footnoteFragment.removeChild(oldFootnote); footnoteMap[id] = footnoteElt; + footnoteFragment.appendChild(footnoteElt); } var footnoteContainerElt; @@ -179,7 +183,12 @@ define([ }, crel('hr'), footnoteElts)); } // Keep used footnotes only in our map - footnoteMap = _.pick(footnoteMap, usedFootnoteIds); + Object.keys(footnoteMap).forEach(function(key) { + if(usedFootnoteIds.indexOf(key) === -1) { + footnoteFragment.removeChild(footnoteMap[key]); + delete footnoteMap[key]; + } + }); } } @@ -226,4 +235,4 @@ define([ }; return partialRendering; -}); \ No newline at end of file +});