Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Vue 3 and Nuxt 3 #265

Open
truesteps opened this issue Jun 15, 2022 · 13 comments · May be fixed by #284
Open

Support Vue 3 and Nuxt 3 #265

truesteps opened this issue Jun 15, 2022 · 13 comments · May be fixed by #284

Comments

@truesteps
Copy link
Contributor

Heya! Are you planning a tag released for vue 3?

@truesteps
Copy link
Contributor Author

@Chantouch i'm working on a vue 3 rewrite, just didn't get to write tests yet, gonna send a pull request asap.... Altho, it seems, sanitize-html doesn't work with Vite :(

@chantouchsek
Copy link
Owner

Lol, Thanks for working on it. Let see if sanitize-html can work with vite. 🍡

@chantouchsek
Copy link
Owner

Can you create a draft PR for it?

@chantouchsek chantouchsek changed the title Vue 3? Support Vue 3 and Nuxt 3 Jul 6, 2022
@truesteps
Copy link
Contributor Author

truesteps commented Jul 7, 2022

#284 added it, as well as sent a bug report for sanitize-html apostrophecms/sanitize-html#553

@chantouchsek chantouchsek linked a pull request Jul 26, 2022 that will close this issue
6 tasks
@danluchs
Copy link
Contributor

danluchs commented Jun 19, 2023

Any movement on this? We'd really like to use this package with our upcoming Nuxt 3 project.

It looks like the issue I'm seeing is on line 55 of src/sanitize.ts, at least for our installation. Nuxt is throwing this error, when trying to set $sanitize on the Vue.prototype:

Cannot set properties of undefined (setting '$sanitize')

This may fix the issue:

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

@chantouchsek
Copy link
Owner

@danluchs feel free to submit a PR for support nuxt 3, I will take a look on it.

@danluchs
Copy link
Contributor

@chantouchsek I'm not sure about the PR process, it doesn't look like I can make a branch?

The issue appears to be on line 55 in the src/sanitize.ts file. The following code should fix things. Nuxt 3/Vue 3 uses the config.globalProperties object vs. the old prototype object.

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

@chantouchsek
Copy link
Owner

How did you try to create a branch?

@chantouchsek
Copy link
Owner

First fork it and commit from your repo

@danluchs
Copy link
Contributor

OK, it's set up, ready for testing:
#598

@chantouchsek
Copy link
Owner

chantouchsek commented Nov 30, 2023

@danluchs did you test on nuxt 3, I think it needs more change for that.

@iandevlin
Copy link

So, does it support Vue 3 now or not?

@chantouchsek
Copy link
Owner

Haven't test on vue 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants