Skip to content

Commit

Permalink
fix(shape): fix possible condition removal by transpiler
Browse files Browse the repository at this point in the history
Condition is removed after the build, where is causing
unexpected issue.
Update condition to not be removed from the build.

Fix #1663
  • Loading branch information
netil authored Sep 9, 2020
1 parent 322beee commit 781fb61
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ChartInternal/internals/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export default {
point = "rect";
}

return document.createElementNS(d3Namespaces.svg, $$.hasValidPointType(point) ? point : "use");
return document.createElementNS(d3Namespaces.svg, ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
})
.attr("class", CLASS.legendItemPoint)
.style("fill", d => $$.color(d))
Expand Down
2 changes: 1 addition & 1 deletion src/ChartInternal/shape/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default {

if (!$$.isTargetToShow(d.id)) {
isWithin = false;
} else if ($$.hasValidPointType && $$.hasValidPointType(that.nodeName)) {
} else if (("hasValidPointType" in $$) && $$.hasValidPointType(that.nodeName)) {
isWithin = $$.isStepType(d) ?
$$.isWithinStep(that, $$.getYScaleById(d.id)(d.value)) :
$$.isWithinCircle(that, $$.isBubbleType(d) ? $$.pointSelectR(d) * 1.5 : 0);
Expand Down
13 changes: 12 additions & 1 deletion test/esm/bar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {expect} from "chai";
import sinon from "sinon";
import bb, {bar} from "../../src/index.esm";
import util from "../assets/util";
import CLASS from "../../src/config/classes";

describe("ESM bar", function() {
let chart;
Expand Down Expand Up @@ -40,4 +39,16 @@ describe("ESM bar", function() {

expect(spy.calledOnce).to.be.true;
});

it("set options: tooltip.grouped=false", () => {
args.tooltip = {
grouped: false
};
});

it("should not throw error", () => {
chart.tooltip.show({x: 1});

expect(true).to.be.ok;
});
});

0 comments on commit 781fb61

Please sign in to comment.