You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@annotator.apache.org by ra...@apache.org on 2020/04/03 01:27:47 UTC

[incubator-annotator] branch master updated (917e7c8 -> 13cc87f)

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

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


    from 917e7c8  highlighter: catch situation where parentNode is null.
     new 2ae6616  Correct demo path in .eslintrc.js
     new 031a077  Set browser environment for dom package linting
     new 13cc87f  yarn run lint

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .eslintrc.js                        |  8 +++++++-
 packages/dom/src/highlight-range.js | 24 ++++++++++++++++++------
 web/demo/index.js                   |  2 +-
 web/webpack.config.js               | 22 +++++++++-------------
 4 files changed, 35 insertions(+), 21 deletions(-)


[incubator-annotator] 01/03: Correct demo path in .eslintrc.js

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2ae66168eac7ea22db5e00231252dfd822e99cae
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Thu Apr 2 18:26:36 2020 -0700

    Correct demo path in .eslintrc.js
---
 .eslintrc.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.eslintrc.js b/.eslintrc.js
index 1e5cef6..9ba0ef7 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -80,7 +80,7 @@ module.exports = {
       },
     },
     {
-      files: ['demo/**/*.js'],
+      files: ['web/demo/**/*.js'],
       env: {
         browser: true,
       },


[incubator-annotator] 03/03: yarn run lint

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 13cc87f7bf19e6cfd2ad71e464ad88a0112e0e54
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Thu Apr 2 18:27:23 2020 -0700

    yarn run lint
---
 packages/dom/src/highlight-range.js | 24 ++++++++++++++++++------
 web/demo/index.js                   |  2 +-
 web/webpack.config.js               | 22 +++++++++-------------
 3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/packages/dom/src/highlight-range.js b/packages/dom/src/highlight-range.js
index 40ab55b..57f76ee 100644
--- a/packages/dom/src/highlight-range.js
+++ b/packages/dom/src/highlight-range.js
@@ -54,7 +54,10 @@ export function highlightRange(range, tagName = 'mark', attributes = {}) {
 // Return an array of the text nodes in the range. Split the start and end nodes if required.
 function textNodesInRange(range) {
   // If the start or end node is a text node and only partly in the range, split it.
-  if (range.startContainer.nodeType === Node.TEXT_NODE && range.startOffset > 0) {
+  if (
+    range.startContainer.nodeType === Node.TEXT_NODE &&
+    range.startOffset > 0
+  ) {
     const endOffset = range.endOffset; // (this may get lost when the splitting the node)
     const createdNode = range.startContainer.splitText(range.startOffset);
     if (range.endContainer === range.startContainer) {
@@ -64,8 +67,8 @@ function textNodesInRange(range) {
     range.setStart(createdNode, 0);
   }
   if (
-    range.endContainer.nodeType === Node.TEXT_NODE
-    && range.endOffset < range.endContainer.length
+    range.endContainer.nodeType === Node.TEXT_NODE &&
+    range.endOffset < range.endContainer.length
   ) {
     range.endContainer.splitText(range.endOffset);
   }
@@ -74,7 +77,10 @@ function textNodesInRange(range) {
   const walker = range.startContainer.ownerDocument.createTreeWalker(
     range.commonAncestorContainer,
     NodeFilter.SHOW_TEXT,
-    node => range.intersectsNode(node) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT,
+    node =>
+      range.intersectsNode(node)
+        ? NodeFilter.FILTER_ACCEPT
+        : NodeFilter.FILTER_REJECT,
   );
   walker.currentNode = range.startContainer;
 
@@ -117,11 +123,17 @@ 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);
+    highlightElement.parentNode.replaceChild(
+      highlightElement.firstChild,
+      highlightElement,
+    );
   } else {
     // If the highlight somehow contains multiple nodes now, move them all.
     while (highlightElement.firstChild) {
-      highlightElement.parentNode.insertBefore(highlightElement.firstChild, highlightElement);
+      highlightElement.parentNode.insertBefore(
+        highlightElement.firstChild,
+        highlightElement,
+      );
     }
     highlightElement.remove();
   }
diff --git a/web/demo/index.js b/web/demo/index.js
index 8fa82e9..3e2332e 100644
--- a/web/demo/index.js
+++ b/web/demo/index.js
@@ -36,7 +36,7 @@ const cleanupFunctions = [];
 
 function cleanup() {
   let removeHighlight;
-  while (removeHighlight = cleanupFunctions.shift()) {
+  while ((removeHighlight = cleanupFunctions.shift())) {
     removeHighlight();
   }
   corpus.normalize();
diff --git a/web/webpack.config.js b/web/webpack.config.js
index 05a8d5c..7876d94 100644
--- a/web/webpack.config.js
+++ b/web/webpack.config.js
@@ -26,14 +26,8 @@ const path = require('path');
 module.exports = {
   context: path.resolve(__dirname),
   entry: {
-    index: [
-      './index.html',
-      './style.css',
-    ],
-    demo: [
-      './demo/index.html',
-      './demo/index.js'
-    ],
+    index: ['./index.html', './style.css'],
+    demo: ['./demo/index.html', './demo/index.js'],
     test: [
       './test/index.html',
       'chai/register-assert',
@@ -50,12 +44,14 @@ module.exports = {
       },
       {
         exclude: /\.js$/,
-        use: [{
-          loader: 'file-loader',
-          options: {
-            name: '[path][name].[ext]',
+        use: [
+          {
+            loader: 'file-loader',
+            options: {
+              name: '[path][name].[ext]',
+            },
           },
-        }],
+        ],
       },
     ],
   },


[incubator-annotator] 02/03: Set browser environment for dom package linting

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 031a077f87ce9d711b3f071551d2741dec8a9a4c
Author: Randall Leeds <ra...@apache.org>
AuthorDate: Thu Apr 2 18:26:52 2020 -0700

    Set browser environment for dom package linting
---
 .eslintrc.js | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.eslintrc.js b/.eslintrc.js
index 9ba0ef7..51592fb 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -106,5 +106,11 @@ module.exports = {
         'import/no-relative-parent-imports': 'off',
       },
     },
+    {
+      files: ['packages/dom/{src,test}/**/*.js'],
+      env: {
+        browser: true,
+      },
+    },
   ],
 };