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

fix: browser cache is always considered stale if .modifyVars wasn't set #3239

Merged
merged 2 commits into from
Jun 27, 2018

Conversation

balpha
Copy link
Contributor

@balpha balpha commented Jun 27, 2018

The problem this fixes is the following: Assume modifyVars is not used, i.e. it's null.

In cache.setCSS, the :vars cache item is not set, because modifyVars is falsy in this if statement.

Therefore, in cache.getCSS, we're retrieving a non-existent item from the cache, and so vars is null.

But modifyVars, which is null at function call time, is them defaulted to {}. In particular, in the check whether the cache is up-to-date, modifyVars is never falsy.

Thus !modifyVars && !vars is never truthy, and the up-to-date decision comes down to
JSON.stringify(modifyVars) === vars, which is "{}" === null and thus false.

So the locally cached version is never used.

@matthew-dean
Copy link
Member

@balpha Good catch! Thanks!

@matthew-dean matthew-dean merged commit c5f18f4 into less:master Jun 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants