Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It seems cache isn't working for getContentModel #1022

Open
nagashimam opened this issue May 13, 2023 · 1 comment
Open

It seems cache isn't working for getContentModel #1022

nagashimam opened this issue May 13, 2023 · 1 comment
Labels

Comments

@nagashimam
Copy link

  • Markuplint version: 3.10.0
  • Parser lang: HTML
  • Node.js version: v18.15.0
  • OS: macOS

Describe the bug

In packages/@markuplint/ml-spec/src/dom-traverse/get-content-model.ts, the result is set to cacheByEl in line 35, but the cache is fetched from cachesBySpecs in line 15.

It seems the original intention was to set the result to cachesBySpecs, not cacheByEl.

Code Example

...
const cachesBySpecs = new Map<Specs, Map<Element, ReadonlyDeep<PermittedContentPattern[]> | boolean | null>>();
...
const cacheByEl = cachesBySpecs.get(specs) ?? new Map<Element, PermittedContentPattern[] | boolean>();
...
cacheByEl.set(el, spec.contentModel.contents);
...

Steps To Reproduce

Just run Markuplint as usual.

The current behavior

ContentModel is calculated every time.

The expected behavior

ContentModel is cached after the first calculation.

@nagashimam nagashimam added the Bug label May 13, 2023
@nagashimam
Copy link
Author

I don't know how to test caching in Jest, but I can create a pull request for this issue if I don't have to add an additional test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant