* remove an unnecessary allocation in cGS
* allocate cGS instances from the stylesheet instead
fixes#2913
Previously the cGS instance count was managed locally in the cGS factory,
which works fine client-side but will never be reset properly for
server-side rendering (in this case, each cGS factory should be reset
to an instance count of 0 per rendering run.)
* Add componentId to "Over 200 classes..." warning
Two minor changes:
- Add optional `componentId` parameter to `src/utils/createWarnTooManyClasses.js` that is then rendered in the warning if it exists.
- Pass in `componentId` in `src/models/StyledComponent.js`
Implements #2776
(cherry picked from commit c1c02425dcd5367bccd543332b8833d29e38b4ee)
* Remove `$FlowFixMe`
This was likely added during rebase / was brought over from the master branch.
(cherry picked from commit 0314552eafc090b63d4bbe2f0f907a2e468b4a30)
* minor adjustments
Co-authored-by: Bee Ellis <44533466+hegelocampus@users.noreply.github.com>
* emit differentiated dynamic hashes for subtrees with different stylis plugins
* reorganize hashing files to avoid a cycle
* prehash the stylis plugin function bodies to make later hashing faster
* look for plugin.name in stylisPlugins for uniqueness
* throw an error instead of a dev-time warning if stylis plugins aren't named
minification can introduce the issue, so a dev warning isn't sufficient
* remove unused fallback code
* use stylis-plugin-rtl
* actually add the plugin
* just use phash
* cache djb2 seed
* add failing test
* aggregate classNames passed via attrs
fixes#2839
Normally attrs fully override the previous value, but in the case of
className they're often composed additively and it's desired to retain
the previous value in a HOC or folding scenario.
* changelog entry [skip ci]
* add simple joining util
* add function signature
* disallow /ad/i in generated class names
fixes#2803
doing a simple replacement for these two characters when they're
preceded by a case-insensitive "a" character since many adblockers
use this as a hook
* simpler logic
* changelog entry
* shard cGS by runtime instance
fixes#2769
cGS has a different injection profile than typical components, in that
there is a single component ID for the global style and any number of
instances. This creates problems when rendering multiple of the same
cGS with different props, as it is a defacto singleton but we don't
enforce a single cGS instance at once...
Utilizing a simple sharding strategy will create duplicate styles, but
ensure that when instances are removed from the page they're taken out
of the stylesheet in the proper order such that previous still-live
instances will continue to function and not be removed as well.
* switch to useRef
* remove the explicit stringification