@vdegenne/highlight-manager 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +14 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -100,11 +100,20 @@ export class HighLightManager {
100
100
  // const highlightIndexStart = elements.findIndex((el) =>
101
101
  // el.hasAttribute('highlight'),
102
102
  // );
103
- if (!highlightElements || highlightElements.length === 0) {
104
- throw Error("The highlighted element couldn't be found");
105
- }
106
- const highlightIndexStart = elements.indexOf(highlightElements[0]);
107
- const highlightIndexEnd = elements.indexOf(highlightElements[highlightElements.length - 1]);
103
+ // if (!highlightElements || highlightElements.length === 0) {
104
+ // console.warn("The highlighted element couldn't be found")
105
+ // return {
106
+ // highlightIndexStart: -1,
107
+ // highlightIndexEnd: -1,
108
+ // elements: []
109
+ // }
110
+ // }
111
+ const highlightIndexStart = highlightElements.length
112
+ ? elements.indexOf(highlightElements[0])
113
+ : -1;
114
+ const highlightIndexEnd = highlightElements.length
115
+ ? elements.indexOf(highlightElements[highlightElements.length - 1])
116
+ : -1;
108
117
  if (highlightElements.length === 1) {
109
118
  // const highlightElement = elements[highlightIndex];
110
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vdegenne/highlight-manager",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "helper to navigate/highlight elements in a page based on a css selector",
5
5
  "type": "module",
6
6
  "exports": {