Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [unreleased]

### Changed
- Clean up mixed Chartist imports
- Clean up mixed Chartist imports ([#2](https://github.com/stklcode/chartist-plugin-tooltip/pull/2))

### Fixed
- Fixed support for multiple custom classes as an array ([#3](https://github.com/stklcode/chartist-plugin-tooltip/pull/3))


## [2.0.0] - 18th April 2026
Expand Down
12 changes: 9 additions & 3 deletions src/scripts/chartist-plugin-tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,15 @@ export default function ChartistPluginTooltip<T extends BaseChart<any>>(
}
if (!tt) {
tt = document.createElement('div');
tt.className = $options.class
? 'chartist-tooltip ' + $options.class
: 'chartist-tooltip';
tt.classList.add('chartist-tooltip');
if ($options.class) {
tt.classList.add(
...([] as string[])
.concat($options.class)
.flatMap(c => c.split(/\s+/))
.filter(Boolean)
);
}
if ($options.appendToBody) {
document.body.appendChild(tt);
} else {
Expand Down
5 changes: 3 additions & 2 deletions test/chartist-plugin-tooltip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Tooltips plugin', () => {
},
{
plugins: [
[ChartistPluginTooltip, {class: 'foo', appendToBody: false}]
[ChartistPluginTooltip, {class: ['foo', 'bar'], appendToBody: false}]
]
}
);
Expand Down Expand Up @@ -120,7 +120,8 @@ describe('Tooltips plugin', () => {
assert.equal(getTooltip()!.style.top, '190px');
});

it('should set additional class', function () {
it('should set additional classes', () => {
assert.equal(hasClass(getTooltip()!, 'foo'), true);
assert.equal(hasClass(getTooltip()!, 'bar'), true);
});
});