DeepFreeze JS variables that are data sources
|Reported by:||elexis||Owned by:||elexis|
|Priority:||Must Have||Milestone:||Alpha 23|
|Component:||UI & Simulation||Keywords:|
Description (last modified by )
GetTechnologyData cache their results in global variables and return these objects each.
However, returning an object means that the reference is returned, not a copy. This isn't an issue if that object was newly created (or cloned). But if the function returns an object which is accessible outside of the scope of the function (f.e. a global cache variable), modifying the returned object modifies the cache, which is not intentional and adulterates the original data.
The mentioned functions should use
Object.freeze to ensure that the returned object can't be modified.
There are likely many other places in
gui/ where global variables are used to cache things, that should be frozen.
Change History (12)
comment:7 by , 3 years ago
|Summary:||Freeze cached session objects → DeepFreeze JS variables that are data sources|