Skip to content

Commit

Permalink
Fix resolver caching issue when setting values (#9938)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Dec 1, 2021
1 parent 688cd47 commit db995af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/helpers/helpers.config.js
Expand Up @@ -76,8 +76,7 @@ export function _createResolver(scopes, prefixes = [''], rootScopes = scopes, fa
*/
set(target, prop, value) {
const storage = target._storage || (target._storage = getTarget());
storage[prop] = value; // set to top level scope
delete target[prop]; // remove from cache
target[prop] = storage[prop] = value; // set to top level scope + cache
delete target._keys; // remove cached keys
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions test/specs/helpers.config.tests.js
Expand Up @@ -492,6 +492,7 @@ describe('Chart.helpers.config', function() {
resolver.value = false;
expect(options.value).toBeFalse();
expect(defaults.value).toBeTrue();
expect(resolver.value).toBeFalse();
});

it('should set values of sub-objects to first scope', function() {
Expand All @@ -505,6 +506,7 @@ describe('Chart.helpers.config', function() {
resolver.sub.value = false;
expect(options.sub.value).toBeFalse();
expect(defaults.sub.value).toBeTrue();
expect(resolver.sub.value).toBeFalse();
});

it('should throw when setting a value and options is frozen', function() {
Expand Down

0 comments on commit db995af

Please sign in to comment.