Skip to content

Commit 689b62a

Browse files
committed
a few more cursorPts guards
1 parent 3735153 commit 689b62a

File tree

5 files changed

+41
-33
lines changed

5 files changed

+41
-33
lines changed

dist/uPlot.cjs.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -3600,7 +3600,7 @@ function uPlot(opts, data, then) {
36003600
function initCursorPt(s, si) {
36013601
let pt = points.show(self, si);
36023602

3603-
if (pt) {
3603+
if (pt instanceof HTMLElement) {
36043604
addClass(pt, CURSOR_PT);
36053605
addClass(pt, s.class);
36063606
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
@@ -5033,7 +5033,7 @@ function uPlot(opts, data, then) {
50335033

50345034
if (showCursor) {
50355035
let pt = cursorOnePt ? cursorPts[0] : cursorPts[i];
5036-
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
5036+
pt != null && elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
50375037
}
50385038
}
50395039
}
@@ -5098,7 +5098,7 @@ function uPlot(opts, data, then) {
50985098
function setAlpha(i, value) {
50995099
series[i].alpha = value;
51005100

5101-
if (showCursor && cursorPts[i])
5101+
if (showCursor && cursorPts[i] != null)
51025102
cursorPts[i].style.opacity = value;
51035103

51045104
if (showLegend && legendRows[i])
@@ -5468,12 +5468,14 @@ function uPlot(opts, data, then) {
54685468
if (shouldSetLegend || focusChanged) {
54695469
let pt = cursorPts[0];
54705470

5471-
cursorPtsLft[0] = _ptLft;
5472-
cursorPtsTop[0] = _ptTop;
5471+
if (pt != null) {
5472+
cursorPtsLft[0] = _ptLft;
5473+
cursorPtsTop[0] = _ptTop;
54735474

5474-
elSize(pt, _ptWid, _ptHgt, _centered);
5475-
elColor(pt, _ptFill, _ptStroke);
5476-
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5475+
elSize(pt, _ptWid, _ptHgt, _centered);
5476+
elColor(pt, _ptFill, _ptStroke);
5477+
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5478+
}
54775479
}
54785480
}
54795481
}

dist/uPlot.esm.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ function uPlot(opts, data, then) {
35983598
function initCursorPt(s, si) {
35993599
let pt = points.show(self, si);
36003600

3601-
if (pt) {
3601+
if (pt instanceof HTMLElement) {
36023602
addClass(pt, CURSOR_PT);
36033603
addClass(pt, s.class);
36043604
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
@@ -5031,7 +5031,7 @@ function uPlot(opts, data, then) {
50315031

50325032
if (showCursor) {
50335033
let pt = cursorOnePt ? cursorPts[0] : cursorPts[i];
5034-
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
5034+
pt != null && elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
50355035
}
50365036
}
50375037
}
@@ -5096,7 +5096,7 @@ function uPlot(opts, data, then) {
50965096
function setAlpha(i, value) {
50975097
series[i].alpha = value;
50985098

5099-
if (showCursor && cursorPts[i])
5099+
if (showCursor && cursorPts[i] != null)
51005100
cursorPts[i].style.opacity = value;
51015101

51025102
if (showLegend && legendRows[i])
@@ -5466,12 +5466,14 @@ function uPlot(opts, data, then) {
54665466
if (shouldSetLegend || focusChanged) {
54675467
let pt = cursorPts[0];
54685468

5469-
cursorPtsLft[0] = _ptLft;
5470-
cursorPtsTop[0] = _ptTop;
5469+
if (pt != null) {
5470+
cursorPtsLft[0] = _ptLft;
5471+
cursorPtsTop[0] = _ptTop;
54715472

5472-
elSize(pt, _ptWid, _ptHgt, _centered);
5473-
elColor(pt, _ptFill, _ptStroke);
5474-
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5473+
elSize(pt, _ptWid, _ptHgt, _centered);
5474+
elColor(pt, _ptFill, _ptStroke);
5475+
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5476+
}
54755477
}
54765478
}
54775479
}

dist/uPlot.iife.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -3601,7 +3601,7 @@ var uPlot = (function () {
36013601
function initCursorPt(s, si) {
36023602
let pt = points.show(self, si);
36033603

3604-
if (pt) {
3604+
if (pt instanceof HTMLElement) {
36053605
addClass(pt, CURSOR_PT);
36063606
addClass(pt, s.class);
36073607
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
@@ -5034,7 +5034,7 @@ var uPlot = (function () {
50345034

50355035
if (showCursor) {
50365036
let pt = cursorOnePt ? cursorPts[0] : cursorPts[i];
5037-
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
5037+
pt != null && elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
50385038
}
50395039
}
50405040
}
@@ -5099,7 +5099,7 @@ var uPlot = (function () {
50995099
function setAlpha(i, value) {
51005100
series[i].alpha = value;
51015101

5102-
if (showCursor && cursorPts[i])
5102+
if (showCursor && cursorPts[i] != null)
51035103
cursorPts[i].style.opacity = value;
51045104

51055105
if (showLegend && legendRows[i])
@@ -5469,12 +5469,14 @@ var uPlot = (function () {
54695469
if (shouldSetLegend || focusChanged) {
54705470
let pt = cursorPts[0];
54715471

5472-
cursorPtsLft[0] = _ptLft;
5473-
cursorPtsTop[0] = _ptTop;
5472+
if (pt != null) {
5473+
cursorPtsLft[0] = _ptLft;
5474+
cursorPtsTop[0] = _ptTop;
54745475

5475-
elSize(pt, _ptWid, _ptHgt, _centered);
5476-
elColor(pt, _ptFill, _ptStroke);
5477-
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5476+
elSize(pt, _ptWid, _ptHgt, _centered);
5477+
elColor(pt, _ptFill, _ptStroke);
5478+
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
5479+
}
54785480
}
54795481
}
54805482
}

dist/uPlot.iife.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uPlot.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ export default function uPlot(opts, data, then) {
989989
function initCursorPt(s, si) {
990990
let pt = points.show(self, si);
991991

992-
if (pt) {
992+
if (pt instanceof HTMLElement) {
993993
addClass(pt, CURSOR_PT);
994994
addClass(pt, s.class);
995995
elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
@@ -2422,7 +2422,7 @@ export default function uPlot(opts, data, then) {
24222422

24232423
if (showCursor) {
24242424
let pt = cursorOnePt ? cursorPts[0] : cursorPts[i];
2425-
pt && elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
2425+
pt != null && elTrans(pt, -10, -10, plotWidCss, plotHgtCss);
24262426
}
24272427
}
24282428
}
@@ -2487,7 +2487,7 @@ export default function uPlot(opts, data, then) {
24872487
function setAlpha(i, value) {
24882488
series[i].alpha = value;
24892489

2490-
if (showCursor && cursorPts[i])
2490+
if (showCursor && cursorPts[i] != null)
24912491
cursorPts[i].style.opacity = value;
24922492

24932493
if (FEAT_LEGEND && showLegend && legendRows[i])
@@ -2857,12 +2857,14 @@ export default function uPlot(opts, data, then) {
28572857
if (shouldSetLegend || focusChanged) {
28582858
let pt = cursorPts[0];
28592859

2860-
cursorPtsLft[0] = _ptLft;
2861-
cursorPtsTop[0] = _ptTop;
2860+
if (pt != null) {
2861+
cursorPtsLft[0] = _ptLft;
2862+
cursorPtsTop[0] = _ptTop;
28622863

2863-
elSize(pt, _ptWid, _ptHgt, _centered);
2864-
elColor(pt, _ptFill, _ptStroke);
2865-
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
2864+
elSize(pt, _ptWid, _ptHgt, _centered);
2865+
elColor(pt, _ptFill, _ptStroke);
2866+
elTrans(pt, ceil(_ptLft), ceil(_ptTop), plotWidCss, plotHgtCss);
2867+
}
28662868
}
28672869
}
28682870
}

0 commit comments

Comments
 (0)