]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Always freeze cached options (#8247)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 29 Dec 2020 13:45:07 +0000 (15:45 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Dec 2020 13:45:07 +0000 (08:45 -0500)
src/core/core.datasetController.js

index 8fbe026319869d86ee5fa59a6078a23682744ca6..4dbc92956a4060bed504131d2ecb5edfd19ed189 100644 (file)
@@ -208,7 +208,6 @@ const optionKeys = (optionNames) => isArray(optionNames) ? optionNames : Object.
 const optionKey = (key, active) => active ? 'hover' + _capitalize(key) : key;
 const isDirectUpdateMode = (mode) => mode === 'reset' || mode === 'none';
 const cloneIfNotShared = (cached, shared) => shared ? cached : Object.assign({}, cached);
-const freezeIfShared = (values, shared) => shared ? Object.freeze(values) : values;
 
 export default class DatasetController {
 
@@ -818,7 +817,8 @@ export default class DatasetController {
                        // We cache options by `mode`, which can be 'active' for example. This enables us
                        // to have the 'active' element options and 'default' options to switch between
                        // when interacting.
-                       cache[mode] = freezeIfShared(values, sharing);
+                       // We freeze a clone of this object, so the returned values are not frozen.
+                       cache[mode] = Object.freeze(Object.assign({}, values));
                }
 
                return values;