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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ dist-demo
website

# Tests Report & Coverage
.jest-cache
jest-coverage
.vitest
**/coverage
**/vitest-coverage
**/cypress-report
Expand Down
16 changes: 16 additions & 0 deletions packages/common/src/core/__tests__/slickGrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7556,6 +7556,22 @@ describe('SlickGrid core file', () => {
expect(secondItemAgeCell.classList.contains('highlight')).toBeFalsy();
});

it('should apply and remove space-separated CSS classes on rendered cells', () => {
grid = new SlickGrid<any, Column>(container, items, columns, { ...defaultOptions, enableCellNavigation: true });
grid.render();

const ageCell = grid.getCellNode(0, 1)!;
const multiClassHash = { 0: { age: 'highlight important' } };

expect(() => grid.addCellCssStyles('multi_class_style', multiClassHash)).not.toThrow();
expect(ageCell.classList.contains('highlight')).toBe(true);
expect(ageCell.classList.contains('important')).toBe(true);

expect(() => grid.removeCellCssStyles('multi_class_style')).not.toThrow();
expect(ageCell.classList.contains('highlight')).toBe(false);
expect(ageCell.classList.contains('important')).toBe(false);
});

it('should merge keyed CSS style overlays before creating a cell', () => {
grid = new SlickGrid<any, Column>(container, items, columns, { ...defaultOptions, enableCellNavigation: true });
grid.addCellCssStyles('primary', { 0: { age: 'primary-highlight' } });
Expand Down
4 changes: 2 additions & 2 deletions packages/common/src/core/slickGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6225,7 +6225,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
if (!addedRowHash || removedRowHash![columnId] !== addedRowHash[columnId]) {
node = this.getCellNode(+row, this.getColumnIndex(columnId));
if (node) {
node.classList.remove(removedRowHash[columnId]);
node.classList.remove(...classNameToList(removedRowHash[columnId]));
}
}
});
Expand All @@ -6236,7 +6236,7 @@ export class SlickGrid<TData = any, C extends Column<TData> = Column<TData>, O e
if (!removedRowHash || removedRowHash[columnId] !== addedRowHash[columnId]) {
node = this.getCellNode(+row, this.getColumnIndex(columnId));
if (node) {
node.classList.add(addedRowHash[columnId]);
node.classList.add(...classNameToList(addedRowHash[columnId]));
}
}
});
Expand Down
Loading