mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
fix: added type Element to the node used in callback in the addhook function
This commit is contained in:
parent
345e82abee
commit
111e067df5
@ -30,21 +30,21 @@ export const removeScript = (txt: string): string => {
|
|||||||
|
|
||||||
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
const TEMPORARY_ATTRIBUTE = 'data-temp-href-target';
|
||||||
|
|
||||||
DOMPurify.addHook('beforeSanitizeAttributes', function (node) {
|
// DOMPurify.addHook('beforeSanitizeAttributes', (node: Element) => {
|
||||||
if (node.tagName === 'A' && node.hasAttribute('target')) {
|
// if (node.tagName === 'A' && node.hasAttribute('target')) {
|
||||||
node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute('target') || '');
|
// node.setAttribute(TEMPORARY_ATTRIBUTE, node.getAttribute('target') || '');
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
// DOMPurify.addHook('afterSanitizeAttributes', (node: Element) => {
|
||||||
if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
// if (node.tagName === 'A' && node.hasAttribute(TEMPORARY_ATTRIBUTE)) {
|
||||||
node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) || '');
|
// node.setAttribute('target', node.getAttribute(TEMPORARY_ATTRIBUTE) || '');
|
||||||
node.removeAttribute(TEMPORARY_ATTRIBUTE);
|
// node.removeAttribute(TEMPORARY_ATTRIBUTE);
|
||||||
if (node.getAttribute('target') === '_blank') {
|
// if (node.getAttribute('target') === '_blank') {
|
||||||
node.setAttribute('rel', 'noopener');
|
// node.setAttribute('rel', 'noopener');
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
const sanitizeMore = (text: string, config: MermaidConfig) => {
|
const sanitizeMore = (text: string, config: MermaidConfig) => {
|
||||||
if (config.flowchart?.htmlLabels !== false) {
|
if (config.flowchart?.htmlLabels !== false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user