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 rule-injection with deferred rules being mutated while used across clones #1892

Merged
merged 3 commits into from Aug 6, 2018

Conversation

Projects
None yet
2 participants
@kitten
Member

kitten commented Aug 6, 2018

Fix #1890

A regression was introduced and not caught in time in #1843 which has gone out recently.

What happens is:

  • Components are created and call deferredInject on a StyleSheet
  • Some clones are created from StyleSheet.master which inherit all deferred arrays
  • The prior two steps might also be in reverse order; doesn't matter
  • inject is called on render which takes deferred rules into account
  • During the injection the deferred[id] array is mutated (to avoid concat)
  • The mutated array is then used in the same manner in other stylesheets, which add the rules that need to be injected again

Hence the outcome is that rules are duplicated for each subsequent clone that injects them.

@kitten kitten requested a review from probablyup Aug 6, 2018

@probablyup

Makes sense :(


// $FlowFixMe
tag.insertRules(id, this.deferred[id], name)
if (this.deferred[id] !== undefined) {

This comment has been minimized.

@probablyup

probablyup Aug 6, 2018

Contributor

Can this be one-lined?

This comment has been minimized.

@kitten

kitten Aug 6, 2018

Member

I suppose it could but ... readability 😅

This comment has been minimized.

@probablyup

probablyup Aug 6, 2018

Contributor

Yeah I was just thinking code size. But it's cool, LGTM

@kitten kitten merged commit 6b55264 into master Aug 6, 2018

3 checks passed

bundlesize Total bundle size is 38.66KB/39.5KB (-10B)
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kitten kitten deleted the fix/post-deferred-injection branch Aug 6, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment