Skip to content

Create the sheet on construction of jss instance #36

@fresheneesz

Description

@fresheneesz

Instead of lazily creating the defaultSheet on set of a rule, create it on construction of jss. I ran across very confusing behavior when I was trying to interact with two different stylesheets using jss. Example:

var jss1 = jss.forDocument(document)
var jss2 = jss.forDocument(document)

jss2.set('#A', {
    color: 'green'
})
jss1.set('#A', {
    color: 'red'
})

I expected element #A to be green after both rules were set, but in fact, the element changes to red. The reason is that the stylesheet is created on the first set instead of on forDocument. It would be much cleaner to create the sheet on construction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions