-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
fix #8862: cannot watch unicode properties like 'a.中文' #8925
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
This is not fixing the issue it says to be fixing 🤔 |
@posva The issue was that Vue was throwing an incorrect warning regarding watchers only watching dot-delimited paths. I added an error to show that Vue does not support using special characters in property naming. However, if this is the route that you think is better I'm open to making another pull request to address this issue. What do you think? |
I think that's a decent workaround, not technically a fix, but I agree with the approach to the original issue. |
src/core/observer/watcher.js
Outdated
@@ -80,13 +80,21 @@ export default class Watcher { | |||
} else { | |||
this.getter = parsePath(expOrFn) | |||
if (!this.getter) { | |||
if (this.getter === false) { |
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.
I don't like that we are relying on magic return values (false
) here, as the logic is separated in two places. Also the check is warning only so it's better to place it right here inside a if (process.env.NODE_ENV !== 'production') { ... }
block, using an inline regexp.
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.
@yyx990803 Thanks for taking the time to review this PR.
I've gone ahead and made the commits to stop relying on random return values. I also tried your suggestion with having the check in an if (process.env.NODE_ENV !== 'production') { ... }
block, but felt that it was unclear to have two regex checks in different places (watcher
and parsePath
) and did not resolve your comment on the logic being separated, so I grouped them together.
Thanks again and please let me know what you think!
Note this may become invalid if we merge #8666, I'm still debating whether we should support it. |
Closed via #8666 |
Hi all at Vue!
This pull request resolves the issue regarding watchers not watching unicode properties like 'a.中文'.
My method for resolving this case is to throw a warning when non-alphanumeric, $, or _ characters are detected. My reasoning behind throwing a warning instead of supporting special characters is that I think supporting special characters would promote poor naming habits that could only make code more difficult to read and understand.
I'm pretty new to open source so any feedback would be awesome and please let me know if you'd like to see any changes or improvements!
Link to issue: #8862
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
dev
branch for v2.x (or to a previous version branch), not themaster
branchfix #xxx[,#xxx]
, where "xxx" is the issue number)If adding a new feature, the PR's description includes: