Skip to content

Commit

Permalink
Merge pull request #598 from danluchs/vue3_fix
Browse files Browse the repository at this point in the history
Changing the Vue prototype object to work with Vue 2 or 3.
  • Loading branch information
chantouchsek authored Jan 18, 2024
2 parents 1de3624 + 55d8999 commit df1b2c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ const VSanitize = {
const { name = 'sanitize' } = defaultOptions;
delete defaultOptions.name
const options1 = { ...defaultOptions } as IOptions
Vue.prototype[`$${name}`] = (dirty: string, opts = undefined) => sanitizeHtml(dirty, opts || options1);

const vueProto = Vue?.config?.globalProperties ?? Vue.prototype;
vueProto[`$${name}`] = (dirty: string, opts = undefined) => sanitizeHtml(dirty, opts || options1);

Vue.directive(name, (el, binding) => {
if (binding.value !== binding.oldValue) {
if (Array.isArray(binding.value)) {
Expand Down

0 comments on commit df1b2c7

Please sign in to comment.