Completely updated React, fixed #11, (hopefully)
This commit is contained in:
63
goTorrentWebUI/node_modules/material-ui/styles/createGenerateClassName.js
generated
vendored
63
goTorrentWebUI/node_modules/material-ui/styles/createGenerateClassName.js
generated
vendored
@@ -11,24 +11,31 @@ var _warning2 = _interopRequireDefault(_warning);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_StyleSheet = require('jss/lib/StyleSheet').babelPluginFlowReactPropTypes_proptype_StyleSheet || require('prop-types').any;
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_generateClassName = require('jss/lib/types').babelPluginFlowReactPropTypes_proptype_generateClassName || require('prop-types').any;
|
||||
|
||||
var babelPluginFlowReactPropTypes_proptype_Rule = require('jss/lib/types').babelPluginFlowReactPropTypes_proptype_Rule || require('prop-types').any;
|
||||
|
||||
var generatorCounter = 0;
|
||||
|
||||
// Returns a function which generates unique class names based on counters.
|
||||
// When new generator function is created, rule counter is reset.
|
||||
// We need to reset the rule counter for SSR for each request.
|
||||
//
|
||||
// It's an improved version of
|
||||
// It's inspired by
|
||||
// https://github.com/cssinjs/jss/blob/4e6a05dd3f7b6572fdd3ab216861d9e446c20331/src/utils/createGenerateClassName.js
|
||||
function createGenerateClassName() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var _options$dangerouslyU = options.dangerouslyUseGlobalCSS,
|
||||
dangerouslyUseGlobalCSS = _options$dangerouslyU === undefined ? false : _options$dangerouslyU,
|
||||
_options$productionPr = options.productionPrefix,
|
||||
productionPrefix = _options$productionPr === undefined ? 'jss' : _options$productionPr;
|
||||
|
||||
var escapeRegex = /([[\].#*$><+~=|^:(),"'`\s])/g;
|
||||
var ruleCounter = 0;
|
||||
|
||||
if (process.env.NODE_ENV === 'production' && typeof window !== 'undefined') {
|
||||
// - HMR can lead to many class name generators being instantiated,
|
||||
// so the warning is only triggered in production.
|
||||
// - We expect a class name generator to be instantiated per new request on the server,
|
||||
// so the warning is only triggered client side.
|
||||
// - You can get away with having multiple class name generators
|
||||
// by modifying the `productionPrefix`.
|
||||
if (process.env.NODE_ENV === 'production' && typeof window !== 'undefined' && productionPrefix === 'jss') {
|
||||
generatorCounter += 1;
|
||||
|
||||
if (generatorCounter > 2) {
|
||||
@@ -37,21 +44,43 @@ function createGenerateClassName() {
|
||||
}
|
||||
}
|
||||
|
||||
return function (rule, sheet) {
|
||||
return function (rule, styleSheet) {
|
||||
ruleCounter += 1;
|
||||
process.env.NODE_ENV !== "production" ? (0, _warning2.default)(ruleCounter < 1e10, ['Material-UI: you might have a memory leak.', 'The ruleCounter is not supposed to grow that much.'].join('')) : void 0;
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return 'c' + ruleCounter;
|
||||
// Code branch the whole block at the expense of more code.
|
||||
if (dangerouslyUseGlobalCSS) {
|
||||
if (styleSheet && styleSheet.options.classNamePrefix) {
|
||||
var prefix = styleSheet.options.classNamePrefix;
|
||||
// Sanitize the string as will be used to prefix the generated class name.
|
||||
prefix = prefix.replace(escapeRegex, '-');
|
||||
|
||||
if (prefix.match(/^Mui/)) {
|
||||
return prefix + '-' + rule.key;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
return prefix + '-' + rule.key + '-' + ruleCounter;
|
||||
}
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return '' + productionPrefix + ruleCounter;
|
||||
}
|
||||
|
||||
return rule.key + '-' + ruleCounter;
|
||||
}
|
||||
|
||||
if (sheet && sheet.options.meta) {
|
||||
var meta = sheet.options.meta;
|
||||
// Sanitize the string as will be used in development to prefix the generated
|
||||
// class name.
|
||||
meta = meta.replace(new RegExp(/[!"#$%&'()*+,./:; <=>?@[\\\]^`{|}~]/g), '-');
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return '' + productionPrefix + ruleCounter;
|
||||
}
|
||||
|
||||
return meta + '-' + rule.key + '-' + ruleCounter;
|
||||
if (styleSheet && styleSheet.options.classNamePrefix) {
|
||||
var _prefix = styleSheet.options.classNamePrefix;
|
||||
// Sanitize the string as will be used to prefix the generated class name.
|
||||
_prefix = _prefix.replace(escapeRegex, '-');
|
||||
|
||||
return _prefix + '-' + rule.key + '-' + ruleCounter;
|
||||
}
|
||||
|
||||
return rule.key + '-' + ruleCounter;
|
||||
|
Reference in New Issue
Block a user