diff --git a/.gitignore b/.gitignore index f3b3edda7..fb3835ba6 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,7 @@ dist-demo website # Tests Report & Coverage -.jest-cache -jest-coverage +.vitest **/coverage **/vitest-coverage **/cypress-report diff --git a/packages/common/src/core/__tests__/slickGrid.spec.ts b/packages/common/src/core/__tests__/slickGrid.spec.ts index 6dde0f72b..adb5691d8 100644 --- a/packages/common/src/core/__tests__/slickGrid.spec.ts +++ b/packages/common/src/core/__tests__/slickGrid.spec.ts @@ -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(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(container, items, columns, { ...defaultOptions, enableCellNavigation: true }); grid.addCellCssStyles('primary', { 0: { age: 'primary-highlight' } }); diff --git a/packages/common/src/core/slickGrid.ts b/packages/common/src/core/slickGrid.ts index 9830b5f77..d4acd2025 100755 --- a/packages/common/src/core/slickGrid.ts +++ b/packages/common/src/core/slickGrid.ts @@ -6225,7 +6225,7 @@ export class SlickGrid = Column, 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])); } } }); @@ -6236,7 +6236,7 @@ export class SlickGrid = Column, 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])); } } });