dequelabs / dequelabs/axe-core
Make the cache inside each Virtual Node consistent with the global cache API
- Dominant language
- JavaScript
- Stars
- 7.5k
- Forks
- 933
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 17
Description
In conjunction with the change to [allow setting a default value through the global `cache.get`](https://github.com/dequelabs/axe-core/issues/3276), it would be great if the [individual cache inside each Virtual Node](https://github.com/dequelabs/axe-core/blob/develop/lib/core/base/virtual-node/virtual-node.js#L29) also had the same API. Currently we have to do a lot of [`if (!this._cache.hasOwnProperty(value))` checking](https://github.com/dequelabs/axe-core/blob/develop/lib/core/base/virtual-node/virtual-node.js#L115) to determine if we need to set an item in node cache. It would be a lot more convenient if we could use a `get` with a default value API.
One way to achieve this is if the cache file had a function to instantiate a new cache with all the APIs, and each Virtual Node called this function to create the individual cache. The global axe cache could also use this function to setup the `cache` export.
Contributor guide
Assessment
This issue has not been assessed yet.