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:50 UTC
[incubator-annotator] 03/03: yarn run lint
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]',
+ },
},
- }],
+ ],
},
],
},