-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix(compiler-sfc): escape non-word characters of css var #6816
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
Conversation
Maybe we could keep replacing symbols to |
but it will cause conflict if there is the same length of symbols. |
We should always keep track of existing ones and add number suffixes to avoid conflicts. |
@antfu IMHO, I don't think it's a good solution. Matching CJK is a complicated feature and it's unnecessary to have this in vue core. To avoid adding complexity, I guess just to escape all non-word characters is enough. After all, it only affects dev mode. |
I think readability is important for dev otherwise we could use hashes as prod. Filtering is quite simple with |
It can only match Chinese characters, but can't Japanese Kana, Korean Hangeul... There are lots of other language characters around the world, e.g. Russian alphabet, and the Greek alphabet. How can vue handle all of them? |
can‘t we keep the unicode characters (in dev) as we do with variable names? After all, they seem to be valid CSS variable names |
@posva I tried Chinese and Japanese characters, and it can work. So maybe can we skip escaping from Unicode characters? |
I found an API Can I add a polyfill dependency css.escape to |
I think it's better to avoid adding any polyfill. If Unicode works and is specified in the spec, let's do that. It should also be the lightest solution |
@posva Updated. It only escapes ASCII punctuation and symbols: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite devtools not highlighting the syntax correctly: the )
looks like it closes the var()
statement
It looks good! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Giving the fact that
and .
are quite common, maybe we could replace them to _
for better readbility?
❌ Deploy Preview for vuejs-coverage failed.
|
…css var names (vuejs#6816) close vuejs#6803
…css var names (vuejs#6816) close vuejs#6803
This bug will affect dev mode only.
closes #6803
ATM, #6815 hasn't been merged. So reproduction cannot reproduce on SFC playground.
Reproduction: