fix typings

This commit is contained in:
falsandtru
2017-08-18 19:09:25 +09:00
parent f0022c8cb3
commit be1e9cb778
2 changed files with 4 additions and 3 deletions

View File

@@ -32,10 +32,11 @@ dompurify.sanitize(dirty, { ADD_ATTR: ['my-attr'] });
dompurify.sanitize(dirty, { ALLOW_DATA_ATTR: false });
// return a DOM HTMLBodyElement instead of an HTML string (default is false)
dompurify.sanitize(dirty, { RETURN_DOM: true });
dompurify.sanitize(dirty, { RETURN_DOM: true }) as HTMLElement;
// return a DOM DocumentFragment instead of an HTML string (default is false)
dompurify.sanitize(dirty, { RETURN_DOM_FRAGMENT: true });
dompurify.sanitize(dirty, { RETURN_DOM_FRAGMENT: true }) as DocumentFragment;
dompurify.sanitize(dirty, { RETURN_DOM_FRAGMENT: true, RETURN_DOM: true }) as DocumentFragment;
// return a DOM DocumentFragment instead of an HTML string (default is false)
// also import it into the current document (default is false).

View File

@@ -10,8 +10,8 @@ declare var DOMPurify: DOMPurify;
interface DOMPurify {
sanitize(source: string | Node): string;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM: true; }): HTMLElement;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM_FRAGMENT: true; }): DocumentFragment;
sanitize(source: string | Node, config: DOMPurifyConfig & { RETURN_DOM: true; }): HTMLElement;
sanitize<T extends string | HTMLElement | DocumentFragment>(source: string | Node, config: DOMPurifyConfig): T;
addHook(hook: 'uponSanitizeElement', cb: (currentNode: Element, data: DOMPurifySanitizeElementHookEvent, config: DOMPurifyConfig) => void): void;
addHook(hook: 'uponSanitizeAttribute', cb: (currentNode: Element, data: DOMPurifySanitizeAttributeHookEvent, config: DOMPurifyConfig) => void): void;