You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ge...@apache.org on 2020/04/02 08:37:31 UTC

[incubator-annotator] branch master updated: highlighter: catch situation where parentNode is null.

This is an automated email from the ASF dual-hosted git repository.

gerben pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-annotator.git


The following commit(s) were added to refs/heads/master by this push:
     new 917e7c8  highlighter: catch situation where parentNode is null.
917e7c8 is described below

commit 917e7c8e463e83c6acd0d3148cd7e393bd0ce952
Author: Gerben <ge...@treora.com>
AuthorDate: Thu Apr 2 10:36:36 2020 +0200

    highlighter: catch situation where parentNode is null.
---
 packages/dom/src/highlight-range.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/packages/dom/src/highlight-range.js b/packages/dom/src/highlight-range.js
index 592f407..40ab55b 100644
--- a/packages/dom/src/highlight-range.js
+++ b/packages/dom/src/highlight-range.js
@@ -114,6 +114,8 @@ function wrapNodeInHighlight(node, tagName, attributes) {
 
 // Remove a highlight element created with wrapNodeInHighlight.
 function removeHighlight(highlightElement) {
+  // If it has somehow been removed already, there is nothing to be done.
+  if (!highlightElement.parentNode) return;
   if (highlightElement.childNodes.length === 1) {
     highlightElement.parentNode.replaceChild(highlightElement.firstChild, highlightElement);
   } else {