diff --git a/src/dom/index.ts b/src/dom/index.ts index be0fdb261..ea6ee83fb 100644 --- a/src/dom/index.ts +++ b/src/dom/index.ts @@ -106,7 +106,13 @@ function hideOriginalFootnote([reference, body]: RefBody): RefBody { function unmountRecursive(element: HTMLElement) { const parent = element.parentElement unmount(element) - if (parent && !parent.innerHTML.trim().replace('[]', '')) { + const html = + parent && + parent.innerHTML + .replace('[]', '') + .replace(' ', ' ') + .trim() + if (parent && !html) { unmountRecursive(parent) } } diff --git a/test/fixtures/backlink.html b/test/fixtures/backlink.html index 5b9bb85d7..eeb9d8a65 100644 --- a/test/fixtures/backlink.html +++ b/test/fixtures/backlink.html @@ -2,6 +2,7 @@
diff --git a/test/setup.test.ts b/test/setup.test.ts index 686f13a86..55a34c588 100644 --- a/test/setup.test.ts +++ b/test/setup.test.ts @@ -57,6 +57,13 @@ test('strips backlink and its enclosing tags from the footnote body', () => { expect(getPopover('1').querySelector('sup')).toBeNull() }) +test('strips backlink and its enclosing tags when they contain whitespace', () => { + setDocumentBody('backlink.html') + littlefoot({ activateDelay: 1 }) + fireEvent.click(getButton('2')) + expect(getPopover('2').querySelector('sup')).toBeNull() +}) + test('preserves empty tags and square brackets elsewhere in the footnote body', () => { setDocumentBody('backlink.html') littlefoot({ activateDelay: 1 }) diff --git a/yarn.lock b/yarn.lock index bfbd36c90..44e756538 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3472,9 +3472,9 @@ ecc-jsbn@~0.1.1: safer-buffer "^2.1.0" electron-to-chromium@^1.3.191: - version "1.3.230" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.230.tgz#2d0618cb6f724391d5fd0926dde84d6c67cbcda9" - integrity sha512-r0RljY5DZi9RX4v8mjHxJkDWnQe+nsrkGlHtrDF2uvZcvAkw+iglvlQi1794gZhwRtJoDOomMJlDHL2LfXSCZA== + version "1.3.232" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.232.tgz#3d812f5082b26b852bd4e98818cd86f10b6ff128" + integrity sha512-11F8S49B+8AJy5V540BofxvJ1tWP4wZZ0sOre6KF32evS1YSHXiUB7+TQ/mjrfzg1lirnlA8XDdU8CDcJrBCbA== elegant-spinner@^1.0.1: version "1.0.1" @@ -4760,9 +4760,9 @@ https-browserify@^1.0.0: integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= husky@^3.0.0: - version "3.0.3" - resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.3.tgz#6f3fb99f60ef72cdf34e5d78445c2f798c441b1d" - integrity sha512-DBBMPSiBYEMx7EVUTRE/ymXJa/lOL+WplcsV/lZu+/HHGt0gzD+5BIz9EJnCrWyUa7hkMuBh7/9OZ04qDkM+Nw== + version "3.0.4" + resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.4.tgz#10a48ac11ab50859b0939750fa0b4e07ad0bf669" + integrity sha512-7Rnt8aJfy+MlV28snmYK7O7vWwtOfeVxV6KhLpUFXlmx5ukQ1nQmNUB7QsAwSgdySB5X+bm7q7JIRgazqBUzKA== dependencies: chalk "^2.4.2" cosmiconfig "^5.2.1" @@ -5965,9 +5965,9 @@ lines-and-columns@^1.1.6: integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= lint-staged@^9.0.0: - version "9.2.1" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.2.1.tgz#57fc5947611604d5a32e478734a13f3e4687f646" - integrity sha512-3lGgJfBddCy/WndKdNko+uJbwyYjBD1k+V+SA+phBYWzH265S95KQya/Wln/UL+hOjc7NcjtFYVCUWuAcqYHhg== + version "9.2.2" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.2.2.tgz#07828263197c5d8ef8f23f86960dccaecb6f9e0a" + integrity sha512-6VFRfqk8RgZmmd52bvCCEH7cBLfQ97ynZd/uATIGM/Rh4EluZbQdY/HXj9kcx7LhX2Zc4+m+4Z6zS74owovLyA== dependencies: chalk "^2.4.2" commander "^2.20.0"