Skip to content

Commit

Permalink
docs: improved ts-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ssi02014 committed Nov 7, 2024
1 parent fbd2ce8 commit 5529184
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 246 deletions.
75 changes: 41 additions & 34 deletions dist/purify.cjs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ interface DOMPurify {
/**
* Set the configuration once.
*
* @param cfg configuration object
* @param {Config} cfg configuration object
* @returns {void}
*/
setConfig(cfg?: Config): void;
/**
Expand All @@ -236,114 +237,120 @@ interface DOMPurify {
/**
* Provides core sanitation functionality.
*
* @param dirty string or DOM node
* @param cfg object
* @return Sanitized TrustedHTML.
* @param {string | Node} dirty string or DOM node
* @param {Config & { RETURN_TRUSTED_TYPE: true }} cfg object
* @returns {TrustedHTML} Sanitized TrustedHTML.
*/
sanitize(dirty: string | Node, cfg: Config & {
RETURN_TRUSTED_TYPE: true;
}): TrustedHTML;
/**
* Provides core sanitation functionality.
*
* @param dirty DOM node
* @param cfg object
* @return Sanitized DOM node.
* @param {Node} dirty DOM node
* @param {Config & { IN_PLACE: true }} cfg object
* @returns {Node} Sanitized DOM node.
*/
sanitize(dirty: Node, cfg: Config & {
IN_PLACE: true;
}): Node;
/**
* Provides core sanitation functionality.
*
* @param dirty string or DOM node
* @param cfg object
* @return Sanitized DOM node.
* @param {string | Node} dirty string or DOM node
* @param {Config & { RETURN_DOM: true }} cfg object
* @returns {Node} Sanitized DOM node.
*/
sanitize(dirty: string | Node, cfg: Config & {
RETURN_DOM: true;
}): Node;
/**
* Provides core sanitation functionality.
*
* @param dirty string or DOM node
* @param cfg object
* @return Sanitized document fragment.
* @param {string | Node} dirty string or DOM node
* @param {Config & { RETURN_DOM_FRAGMENT: true }} cfg object
* @returns {DocumentFragment} Sanitized document fragment.
*/
sanitize(dirty: string | Node, cfg: Config & {
RETURN_DOM_FRAGMENT: true;
}): DocumentFragment;
/**
* Provides core sanitation functionality.
*
* @param dirty string or DOM node
* @param cfg object
* @return Sanitized string.
* @param { string | Node} dirty string or DOM node
* @param {Config} cfg object
* @returns {string} Sanitized string.
*/
sanitize(dirty: string | Node, cfg?: Config): string;
/**
* Checks if an attribute value is valid.
* Uses last set config, if any. Otherwise, uses config defaults.
*
* @param tag Tag name of containing element.
* @param attr Attribute name.
* @param value Attribute value.
* @return Returns true if `value` is valid. Otherwise, returns false.
* @param {string} tag Tag name of containing element.
* @param {string} attr Attribute name.
* @param {string} value Attribute value.
* @returns {boolean} Returns true if `value` is valid. Otherwise, returns false.
*/
isValidAttribute(tag: string, attr: string, value: string): boolean;
/**
* Adds a DOMPurify hook.
*
* @param entryPoint entry point for the hook to add
* @param hookFunction function to execute
* @param {BasicHookName} entryPoint entry point for the hook to add
* @param {Hook} hookFunction function to execute
* @returns {void}
*/
addHook(entryPoint: 'beforeSanitizeElements' | 'afterSanitizeElements' | 'beforeSanitizeAttributes' | 'afterSanitizeAttributes' | 'beforeSanitizeShadowDOM' | 'uponSanitizeShadowNode' | 'afterSanitizeShadowDOM', hookFunction: Hook): void;
addHook(entryPoint: BasicHookName, hookFunction: Hook): void;
/**
* Adds a DOMPurify hook.
*
* @param entryPoint entry point for the hook to add
* @param hookFunction function to execute
* @param {'uponSanitizeElement'} entryPoint entry point for the hook to add
* @param {UponSanitizeElementHook} hookFunction function to execute
* @returns {void}
*/
addHook(entryPoint: 'uponSanitizeElement', hookFunction: UponSanitizeElementHook): void;
/**
* Adds a DOMPurify hook.
*
* @param entryPoint entry point for the hook to add
* @param hookFunction function to execute
* @param {'uponSanitizeAttribute'} entryPoint entry point for the hook to add
* @param {UponSanitizeAttributeHook} hookFunction function to execute
* @returns {void}
*/
addHook(entryPoint: 'uponSanitizeAttribute', hookFunction: UponSanitizeAttributeHook): void;
/**
* Remove a DOMPurify hook at a given entryPoint
* (pops it from the stack of hooks if more are present)
*
* @param entryPoint entry point for the hook to remove
* @return removed(popped) hook
* @param {BasicHookName} entryPoint entry point for the hook to remove
* @returns {Hook | undefined} removed(popped) hook
*/
removeHook(entryPoint: BasicHookName): Hook | undefined;
/**
* Remove a DOMPurify hook at a given entryPoint
* (pops it from the stack of hooks if more are present)
*
* @param entryPoint entry point for the hook to remove
* @return removed(popped) hook
* @param {'uponSanitizeElement'} entryPoint entry point for the hook to remove
* @returns {UponSanitizeElementHook | undefined} removed(popped) hook
*/
removeHook(entryPoint: 'uponSanitizeElement'): UponSanitizeElementHook | undefined;
/**
* Remove a DOMPurify hook at a given entryPoint
* (pops it from the stack of hooks if more are present)
*
* @param entryPoint entry point for the hook to remove
* @return removed(popped) hook
* @param {'uponSanitizeAttribute'} entryPoint entry point for the hook to remove
* @returns {UponSanitizeAttributeHook | undefined} removed(popped) hook
*/
removeHook(entryPoint: 'uponSanitizeAttribute'): UponSanitizeAttributeHook | undefined;
/**
* Removes all DOMPurify hooks at a given entryPoint
*
* @param entryPoint entry point for the hooks to remove
* @param {HookName} entryPoint entry point for the hooks to remove
* @returns {void}
*/
removeHooks(entryPoint: HookName): void;
/**
* Removes all DOMPurify hooks.
*
* @returns {void}
*/
removeAllHooks(): void;
}
Expand Down
43 changes: 17 additions & 26 deletions dist/purify.cjs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/purify.cjs.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5529184

Please sign in to comment.