Skip to content

Does not work when used through a Vue Mixin #39

Description

@brian-gonzalez

Hello!

We have a setup where we share a mixin through multiple Vue components, and were hoping that this plugin would work with said structure.

This is a sample of the configuration:

The mixin:

import DOMPurify from "dompurify";

export default {
  props: {
    description: {
      type: String,
      default: "",
    },
  },
  computed: {
    sanitizedDescription() {
      return DOMPurify.sanitize(this.description);
    },
  },
};

A component (:

<template>
    <div v-html="sanitizedDescription"></div>
</template>

<script>
    import TextMixin from "path/to/text/mixin";

    export default {
        name: "ComponentName",
        mixins: [ TextMixin ],
    }
</script>

Using this approach we get the eslint error: "XSS potentially found: use of v-html"

Of course, adding the computed functions within each component does work as intended, but we wanted to see if it was possible to reduce repeated code.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions