jss: insertionPoint option is not used for createStyleSheet function

Checked the code

  createStyleSheet(styles: Object, options: StyleSheetFactoryOptions = {}): StyleSheet {
    let index = options.index
    if (typeof index !== 'number') {
      index = sheets.index === 0 ? 0 : sheets.index + 1
    }
    const sheet = new StyleSheet(styles, {
      ...options,
      jss: (this: Jss),
      generateClassName: options.generateClassName || this.generateClassName,
      insertionPoint: this.options.insertionPoint,
      Renderer: this.options.Renderer,
      index
    })
    this.plugins.onProcessSheet(sheet)
    return sheet
  }

Even though you pass your insertionPoint in options it will be overwritten by default setting…

Found it while using new material ui beta release.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, I configured JssProvider and passed jss instance to it.

const jss = create(preset());
jss.options.createGenerateClassName = createGenerateClassName;
jss.options.injectionPoint = 'material-ui';

and it is not working.

I console log the sheet from https://github.com/callemall/material-ui/blob/v1-beta/src/styles/withStyles.js#L140 sheet Jss is set correctly. But still the injectionPoint option set for StyleSheet has higher priority then jss instance. When I overwrite the insertionPoint for sheet

              var sheet = _this3.jss.createStyleSheet(styles, (0, _extends3.default)({
                meta: name,
                name: name,
                insertionPoint: _themeListener.CHANNEL,
                link: false
              }, _this3.sheetOptions, currentStyleSheet.options));
              sheet.options.insertionPoint = _themeListener.CHANNEL;

then it works.

So, @kof looks like createStyleSheet is broken because it will always set undefined as insertionPoint.