Skip to content

Commit

Permalink
Fix tooltips options accepting a Formatter #1101
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed May 20, 2021
1 parent 3dcbcf7 commit 67db470
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### 15.1.1 (*2021-05-09*)
- Fixed: `tooltips` option accepts one `Formatter` for all tooltips (#1101);

### 15.1.0 (*2021-05-09*)
- Added: `drag` event when dragging connecting elements (#887, #1135);

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nouislider",
"version": "15.1.0",
"version": "15.1.1",
"main": "dist/nouislider.js",
"style": "dist/nouislider.min.css",
"types": "dist/nouislider.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions src/nouislider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ type EventCallback = (

//region Helper Methods

function isValidFormatter(entry: Formatter): entry is Formatter {
return typeof entry === "object" && typeof entry.to === "function" && typeof entry.from === "function";
function isValidFormatter(entry: unknown): entry is Formatter {
return typeof entry === "object" && typeof (<Formatter>entry).to === "function" && typeof (<Formatter>entry).from === "function";
}

function removeElement(el: HTMLElement): void {
Expand Down Expand Up @@ -1153,11 +1153,11 @@ function testTooltips(parsed: ParsedOptions, entry: boolean | Formatter | (boole
return;
}

if (entry === true) {
if (entry === true || isValidFormatter(entry)) {
parsed.tooltips = [];

for (let i = 0; i < parsed.handles; i++) {
parsed.tooltips.push(true);
parsed.tooltips.push(entry);
}
} else {
entry = asArray(entry);
Expand Down

0 comments on commit 67db470

Please sign in to comment.