van icon indicating copy to clipboard operation
van copied to clipboard

Refactor Van State to remove prototype to do reactive updates

Open 64BitAsura opened this issue 1 year ago • 1 comments
trafficstars

As we know, we use proto to do expose synthetic properties like val and oldVal of the given state. But current browsers are depreciating usage of proto- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto

Screenshot 2023-12-20 180732

We should refactor to make this wonderful neat rendering technique update to do for modern browser baselines

64BitAsura avatar Dec 20 '23 17:12 64BitAsura

Thanks for raising this interesting point! The __proto__ property is a tricky topic in JavaScript and understandably there are misunderstandings about it among developers. This is not the first time when people raised this issue.

On the other hand, after reading all the relevant docs, my conclusion is: the way that VanJS is doing with __proto__ is well supported by modern web-standard thus there is no concern on potentially losing support in future browser versions. In the same page you linked, please note that:

image

Also, see this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#prototype_setter for more clarity.

Tao-VanJS avatar Dec 20 '23 18:12 Tao-VanJS