rofrischmann/react-look

View on GitHub
packages/react-look/modules/prefixer/DynamicPrefixer.js

Summary

Maintainability
A
0 mins
Test Coverage
import Prefixer from '../api/Prefixer'
import InlineStylePrefixer from 'inline-style-prefixer'

/**
 * Dynamic Prefixer which validate the userAgent to prefix styles
 * @param {string} userAgent - optional userAgent that gets used to gather information on prefixes
 */
export default class DynamicPrefixer extends Prefixer {
  constructor(config) {
    super()
    this.config = config
    this._prefixer = new InlineStylePrefixer(config)
  }

  prefix(styles) {
    return this._prefixer.prefix(styles)
  }

  getKeyframesPrefix() {
    const keyframesPrefix = [ this._prefixer.cssPrefix ]
    return this.config.keepUnprefixed ? keyframesPrefix.concat('') : keyframesPrefix
  }
}