-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[FR] Support console
in the template
#7939
Comments
Console API is not a built-in JavaScript API and I think the most important is that it has side effects. It will be executed multiple times when re-rendering, so it's not suitable to use it in |
@sxzz Does Svelte have the same issue?
If the template |
see #3450 (comment) |
One of the first things we do when we encounter bugs is to console log the errors, also, the first thing in programming that we learn is to print something. It's just ridiculous such a fundamental thing can't used be in the template, we do console log in JSX and in the Svelte template all the time, and it doesn't hurt anybody. If the template is deliberately made so limited, no wonder some JSX fans call it a toy. |
But I want know does console work in render() function? like |
yes it can, but it should be () => console.log('hi'), |
@sxzz If we want to discourage |
The template global whitelist has always only included language-level globals (as defined in ECMA-262). When Vue was initially created, However, there is now an actual spec for it, and it seems all major JS runtimes do implement console the same way nowadays, so we can consider adding it as a special case for the concrete DX improvement. |
@yyx990803 Evan, can we add console support in the template in v3.3? Here's the PR. |
What problem does this feature solve?
I don't understand, why
console
can't be used in the template since Vue 2, it makes template debugging much more complicated than it needs to be, Svelte supportsconsole
in the template out of the box, can Vue be more user friendly in this regard?What does the proposed API look like?
If we want to discourage
console
usage in the templates, it can be achieved using eslint lint rules, but not usable at all is a complete overkill.The text was updated successfully, but these errors were encountered: