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

fix(compiler-sfc): consistently escape type-only prop names #8654

Merged

Conversation

auvred
Copy link
Contributor

@auvred auvred commented Jun 26, 2023

fixes #8635
fixes #8910
fixes vitejs/vite-plugin-vue#184


The first and second issues were caused by RegExp.test() called on stateful regular expression with g flag

const re = /a/g

re.test('a') // true
re.test('a') // false
re.test('a') // true
re.test('a') // false

The third issue was caused by a missed dash in the escapeSymbolsRE regex

I decided to fix the second issue in this pull request in order to include it to the new test case to avoid possible merge difficulties in the future

@auvred
Copy link
Contributor Author

auvred commented Jun 27, 2023

This regex is also used for css var names escaping, but the dash is allowed symbol there. I'm not sure if I properly handled this case. Maybe we should use two different regular expressions: one for type-only props names and another one for css var names?

@sxzz
Copy link
Member

sxzz commented Aug 13, 2023

@auvred Yes. We can separate it into two regex patterns. It doesn't really work in two cases.

@sxzz sxzz added the ready to merge The PR is ready to be merged. label Aug 13, 2023
@yyx990803 yyx990803 merged commit 3e08d24 into vuejs:main Nov 10, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR is ready to be merged.
Projects
4 participants