Skip to content

Commit

Permalink
chore: remove any deprecated code leftover (#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Apr 27, 2024
1 parent 3c22b3e commit dce7c44
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 31 deletions.
8 changes: 5 additions & 3 deletions docs/migrations/migration-to-5.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ or move the class to the parent container and have both the icon and the text in
</button>
```

### 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.

Expand All @@ -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.

Expand Down
10 changes: 0 additions & 10 deletions packages/common/src/formatters/__tests__/iconFormatter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"');
Expand All @@ -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(`<i class="${icon}" aria-hidden="true"></i>`);
});

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(`<i class="${icon}" aria-hidden="true"></i>`);
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" }}`');
});
});
4 changes: 0 additions & 4 deletions packages/common/src/formatters/iconFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}`');
}
Expand Down
6 changes: 2 additions & 4 deletions packages/utils/src/__tests__/domUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<span>some text</span>');
expect(result2).toBe('<span>some text</span>');
expect(result).toBe('<span>some text</span>');
});

it('should return outerHTML from fragment', () => {
Expand Down
8 changes: 0 additions & 8 deletions packages/utils/src/domUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ export function emptyElement<T extends Element = Element>(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.
Expand Down
2 changes: 0 additions & 2 deletions test/jest-global-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit dce7c44

Please sign in to comment.