From dce7c4491a72e3ea0026ccc5c8337805e25c0228 Mon Sep 17 00:00:00 2001 From: Ghislain B Date: Sat, 27 Apr 2024 16:52:14 -0400 Subject: [PATCH] chore: remove any deprecated code leftover (#1489) --- docs/migrations/migration-to-5.x.md | 8 +++++--- .../src/formatters/__tests__/iconFormatter.spec.ts | 10 ---------- packages/common/src/formatters/iconFormatter.ts | 4 ---- packages/utils/src/__tests__/domUtils.spec.ts | 6 ++---- packages/utils/src/domUtils.ts | 8 -------- test/jest-global-mocks.ts | 2 -- 6 files changed, 7 insertions(+), 31 deletions(-) diff --git a/docs/migrations/migration-to-5.x.md b/docs/migrations/migration-to-5.x.md index 5c7278701..cdfa8c077 100644 --- a/docs/migrations/migration-to-5.x.md +++ b/docs/migrations/migration-to-5.x.md @@ -54,8 +54,6 @@ or move the class to the parent container and have both the icon and the text in ``` -### Deprecated code removed/renamed - ##### SASS variables A lot of SASS variables changed, we recommend you take a look at the [_variables.scss](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/styles/_variables.scss) file to compare with yours SASS overrides and fix any SASS build issues. @@ -81,7 +79,11 @@ There were a few `.ui-state-default` and other jQueryUI CSS classes leftovers in } ``` -### Formatters Cleanup & Removals +### Deprecated code removed/renamed +##### `getHTMLFromFragment()` removed +The function `getHTMLFromFragment()` was removed in favor of `getHtmlStringOutput()`, the new function will auto-detect if it's a DocumentFragment, an HTMLElement or an HTML string and will execute the appropriate action. + +#### Formatters Cleanup & Removals Since we now only use SVG and we got rid of any Font usage (no more Font-Awesome code anywhere), the `checkmark` Formatter no longer has any reason to exist and was removed. If you were using and still use Font-Awesome in your project, you'll have to either recreate the Formatter yourself or use alternatives. You could use the `Formatters.icon` or `Formatters.iconBoolean` which require the CSS classes to be provided via `params`. As a last alternative, and if you are importing the optional SVG icons `.mdi`, then we recommend you simply use the `checkmarkMaterial` Formatter. diff --git a/packages/common/src/formatters/__tests__/iconFormatter.spec.ts b/packages/common/src/formatters/__tests__/iconFormatter.spec.ts index 671fff9dc..aef8cd42a 100644 --- a/packages/common/src/formatters/__tests__/iconFormatter.spec.ts +++ b/packages/common/src/formatters/__tests__/iconFormatter.spec.ts @@ -2,8 +2,6 @@ import { Column } from '../../interfaces/index'; import { iconFormatter } from '../iconFormatter'; describe('the Icon Formatter', () => { - const consoleWarnSpy = jest.spyOn(global.console, 'warn').mockReturnValue(); - it('should throw an error when omitting to pass "propertyNames" to "params"', () => { expect(() => iconFormatter(0, 0, 'anything', {} as Column, {}, {} as any)) .toThrowError('[Slickgrid-Universal] When using `Formatters.icon`, you must provide the "iconCssClass" via the generic "params"'); @@ -22,12 +20,4 @@ describe('the Icon Formatter', () => { const result = iconFormatter(0, 0, input, { field: 'user', params: { formatterIcon: icon } } as Column, {}, {} as any); expect((result as HTMLElement).outerHTML).toBe(``); }); - - it('should show console warning when using deprecated icon/formatterIcon params', () => { - const input = null; - const icon = 'mdi mdi-magnify'; - const result = iconFormatter(0, 0, input, { field: 'user', params: { icon } } as Column, {}, {} as any); - expect((result as HTMLElement).outerHTML).toBe(``); - expect(consoleWarnSpy).toHaveBeenCalledWith('[Slickgrid-Universal] deprecated params.icon or params.formatterIcon are deprecated when using `Formatters.icon` in favor of params.iconCssClass. (e.g.: `{ formatter: Formatters.icon, params: { iconCssClass: "mdi mdi-magnify" }}`'); - }); }); diff --git a/packages/common/src/formatters/iconFormatter.ts b/packages/common/src/formatters/iconFormatter.ts index 6d3ac400e..4b39f7788 100644 --- a/packages/common/src/formatters/iconFormatter.ts +++ b/packages/common/src/formatters/iconFormatter.ts @@ -6,10 +6,6 @@ import { type Formatter } from './../interfaces/index'; export const iconFormatter: Formatter = (_row, _cell, _value, columnDef) => { const columnParams = columnDef?.params ?? {}; const cssClasses = columnParams.iconCssClass || columnParams.icon || columnParams.formatterIcon; - if (columnParams.icon || columnParams.formatterIcon) { - console.warn('[Slickgrid-Universal] deprecated params.icon or params.formatterIcon are deprecated when using `Formatters.icon` in favor of params.iconCssClass. (e.g.: `{ formatter: Formatters.icon, params: { iconCssClass: "mdi mdi-magnify" }}`'); - } - if (!cssClasses) { throw new Error('[Slickgrid-Universal] When using `Formatters.icon`, you must provide the "iconCssClass" via the generic "params". (e.g.: `{ formatter: Formatters.icon, params: { iconCssClass: "mdi mdi-magnify" }}`'); } diff --git a/packages/utils/src/__tests__/domUtils.spec.ts b/packages/utils/src/__tests__/domUtils.spec.ts index 6875c9246..855885bc6 100644 --- a/packages/utils/src/__tests__/domUtils.spec.ts +++ b/packages/utils/src/__tests__/domUtils.spec.ts @@ -164,11 +164,9 @@ describe('Service/domUtilies', () => { div.appendChild(span); fragment.appendChild(div); - const result1 = getHTMLFromFragment(fragment); // deprecated - const result2 = getHtmlStringOutput(fragment); + const result = getHtmlStringOutput(fragment); - expect(result1).toBe('some text'); - expect(result2).toBe('some text'); + expect(result).toBe('some text'); }); it('should return outerHTML from fragment', () => { diff --git a/packages/utils/src/domUtils.ts b/packages/utils/src/domUtils.ts index 933e08e6a..eb8dc359f 100644 --- a/packages/utils/src/domUtils.ts +++ b/packages/utils/src/domUtils.ts @@ -103,14 +103,6 @@ export function emptyElement(element?: T | null): T return element; } -/** - * @deprecated @see `getHtmlStringOutput()` - * This function is now deprecated and is an alias to the new `getHtmlStringOutput()`, so please use this new function instead which works with various type of inputs. - */ -export function getHTMLFromFragment(input: DocumentFragment | HTMLElement | string | number, type: 'innerHTML' | 'outerHTML' = 'innerHTML'): string { - return getHtmlStringOutput(input, type); -} - /** * From any input provided, return the HTML string (when a string is provided, it will be returned "as is" but when it's a number it will be converted to string) * When detecting HTMLElement/DocumentFragment, we can also specify which HTML type to retrieve innerHTML or outerHTML. diff --git a/test/jest-global-mocks.ts b/test/jest-global-mocks.ts index 70dd0af79..0692d4a7b 100644 --- a/test/jest-global-mocks.ts +++ b/test/jest-global-mocks.ts @@ -32,8 +32,6 @@ Object.defineProperty(window, 'matchMedia', { matches: false, media: query, onchange: null, - addListener: jest.fn(), // Deprecated - removeListener: jest.fn(), // Deprecated addEventListener: jest.fn(), removeEventListener: jest.fn(), dispatchEvent: jest.fn(),