LeSuisse/vue-dompurify-html

Hook registration

luxaritas opened this issue · 1 comments

Currently I'm adding hooks by adding dompurify as a proper dependency and using DOMPurify.addHook. Would it make sense to more closely integrate hooks in this library somehow?

Hello,

It would need to be part of the global configuration of the directive because we cannot set the hooks when we call DOMPurify.sanitize but it's doable.

In fact it becomes mandatory if we want to have an independent instance of DOMPurify for the directive because something like below becomes impossible.

import Vue from 'vue';
import VueDOMPurifyHTML from 'vue-dompurify-html';
import { addHook } from "dompurify";

addHook("uponSanitizeElement", function (el) {
    // Do something
});
Vue.use(VueDOMPurifyHTML);

This is likely something that will happen for the v3 (planned for the release of Vue 3) because I would like to prevent potential misuses of DOMPurify.setConfig() to change the behavior of the directive.
The configuration section can however comes first and be integrated in the current v2 ;) .