cssinjs / cssinjs/jss

[jss-plugin-cache] don't set the selector when rule was cached before

Open
#813 1 comment 0 reactions 0 assignees View on GitHub
bug complexity:moderate important
Dominant language
JavaScript
Stars
7.1k
Forks
386
PR merge metrics
No merged PRs in 30d

Description

Currently, when the cache plugin returns a cached rule from onCreateRule, we still generate a new class name and set the selector [here](https://github.com/cssinjs/jss/blob/92a53e4da49749b46b300eeae7bc6fadcc006931/packages/jss/src/RuleList.js#L77).

The problem with this is that in case the selector was modified before by a custom plugin, we are removing the modification.

Problems:
- we still need to get back the class name, currently className is not saved on the StyleRule instance, because its hard to keep it consistently with .selector property.

Eventually we should still save somewhere the 'generatedClassName' and be able to use it to register a rule comming from the cache.

Contributor guide

Open the contributing guide

Research direction

Start at packages/jss/src/RuleList.js around line 77 and trace how the cache plugin's onCreateRule result is handled, including the StyleRule selector and className state. Done means a cached rule preserves selector changes made by a custom plugin while its generated class name remains available for registration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.