Skip to content

Commit

Permalink
fix(build): add DOM purify optional default import to fix rollup builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Nov 19, 2021
1 parent 403679b commit 73bc3c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/binding/src/binding.service.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/common/src/services/domUtilities.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 73bc3c0

Please sign in to comment.