-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
[Vapor] Bad optimization for some functions #14560
Copy link
Copy link
Closed
Labels
🐞 bugSomething isn't workingSomething isn't workingscope: vaporrelated to vapor moderelated to vapor mode
Description
Vue version
3.6.0-beta.7
Link to minimal reproduction
Steps to reproduce
- Create a Vapor component
- Add 2 div containing Math.random
What is expected?
Each divs containing a different random values
What is actually happening?
Both divs contains the same value
System Info
Any additional comments?
Maybe related to #14561
Inside the generated _renderEffect function Math.random() is called once and stored in one variable (see below), it should create one variable for each functions instead.
This is working properly in <script> and <script setup>
Generated _renderEffect
_renderEffect(() => {
const _Math_random = Math.random()
_setText(x0, "random1: " + _toDisplayString(_Math_random))
_setText(x1, "random2: " + _toDisplayString(_Math_random))
})As #14561 is closed, adding info here for this error:
An error on first load and reload seems that ctx. is prepended to Math.random and parentheses are not present
Generated _renderEffect
_renderEffect(() => {
const _Math_random = _ctx.Math_random
_setText(x0, "random1: " + _toDisplayString(_Math_random))
_setText(x1, "random2: " + _toDisplayString(_Math_random))
})Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🐞 bugSomething isn't workingSomething isn't workingscope: vaporrelated to vapor moderelated to vapor mode