diff --git a/packages/binding/src/binding.service.ts b/packages/binding/src/binding.service.ts index f7a0c6d98..05ce9c25e 100644 --- a/packages/binding/src/binding.service.ts +++ b/packages/binding/src/binding.service.ts @@ -1,6 +1,6 @@ /* eslint-disable no-bitwise */ import * as DOMPurify_ from 'dompurify'; -const DOMPurify = DOMPurify_; // patch to fix rollup to work +const DOMPurify = (DOMPurify_ as any)['default'] || DOMPurify_; // patch to fix rollup to work interface Binding { variable: any; diff --git a/packages/common/src/services/domUtilities.ts b/packages/common/src/services/domUtilities.ts index d32fdcdb2..098207477 100644 --- a/packages/common/src/services/domUtilities.ts +++ b/packages/common/src/services/domUtilities.ts @@ -1,5 +1,5 @@ import * as DOMPurify_ from 'dompurify'; -const DOMPurify = DOMPurify_; // patch to fix rollup to work +const DOMPurify = (DOMPurify_ as any)['default'] || DOMPurify_; // patch to fix rollup to work import { InferDOMType, SearchTerm } from '../enums/index'; import { Column, GridOption, HtmlElementPosition, SelectOption, SlickGrid, } from '../interfaces/index'; @@ -320,9 +320,9 @@ export function sanitizeHtmlToText(htmlString: string): string { */ export function sanitizeTextByAvailableSanitizer(gridOptions: GridOption, dirtyHtml: string, domPurifyOptions?: DOMPurify.Config): string { let sanitizedText = dirtyHtml; - if (gridOptions && typeof gridOptions.sanitizer === 'function') { + if (typeof gridOptions?.sanitizer === 'function') { sanitizedText = gridOptions.sanitizer(dirtyHtml || ''); - } else if (typeof DOMPurify.sanitize === 'function') { + } else if (typeof DOMPurify?.sanitize === 'function') { sanitizedText = (DOMPurify.sanitize(dirtyHtml || '', domPurifyOptions || {}) || '').toString(); }