jss: index precedence not working on root element

https://github.com/cssinjs/jss/blob/master/docs/js-api.md#attach-style-sheets-in-a-specific-order

I’m trying to take precedence in styling over the material-ui#next Paper element that specifies index: -10 with my stylesheet index: 1 on my root element:

const styleSheet = createStyleSheet('AfRoot', (theme) => {
  const { breakpoints } = theme
  return {
    root: {
      display: 'flex'
    }
  }
}, { index: 1 })

landing_-_dummy_com

This led me to think (based on the docs) that the lower the index, the higher the precedence, so I tried changing my index from 1 to -100 and it still did not take precedence. I captured the order of attachment and indexes in the debugger:

DummyAppFrame
AfGlobal {named: false}
AfRoot: -100
AfAppBar
AppBar: -5
Paper: -10
Toolbar: -1
IconButton: -10
Ripple: -15
Text: -10
AfAppDrawer
Drawer: -5
AfLanding
AfDialog: 100

Which yielded: landing_-_dummy_com

So Toolbar: -1 has a higher precedence than Paper: -10 - I’m having hard making sense of this.

  1. Is it true that the lower the number (including negatives), the higher the precedence? No, higher number should be more specific.
  2. How does an undefined index factor in, as a zero? As 0.
  3. What is the recommended practice values a library should use for index precedence? e.g. should material-ui be using higher numbers?
  4. Is this a bug?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (16 by maintainers)

Most upvoted comments

Also @rosskevin I’ll be refactoring how priority is set for mui next this weekend. Nothing is going to be put in individual stylesheets anymore. We’ll have everything in a centralized location for configuring that. I’ll reference this issue when I make the PR.