Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
if (context === -2) {
var parsedRules = parsingRules;
parsingRules = [];
return parsedRules;
}
};
var parseRulesPlugin = _insertRulePlugin(function (rule) {
parsingRules.push(rule);
});
stylis.use([parseRulesPlugin, returnRulesPlugin]);
stylisSplitter.use([parseRulesPlugin, returnRulesPlugin]);
var splitByRules = function splitByRules(css) {
return stylisSplitter('', css);
};
//
/* eslint-disable camelcase, no-undef */
var getNonce = (function () {
return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
});
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
let parsingRules = [];
// eslint-disable-next-line consistent-return
const returnRulesPlugin = context => {
if (context === -2) {
const parsedRules = parsingRules;
parsingRules = [];
return parsedRules;
}
};
const parseRulesPlugin = _insertRulePlugin(rule => {
parsingRules.push(rule);
});
let _componentId: string;
let _selector: string;
let _selectorRegexp: RegExp;
const selfReferenceReplacer = (match, offset, string) => {
if (
// the first self-ref is always untouched
offset > 0 &&
// there should be at least two self-refs to do a replacement (.b > .b)
string.slice(0, offset).indexOf(_selector) !== -1 &&
// no consecutive self refs (.b.b); that is a precedence boost and treated differently
string.slice(offset - _selector.length, offset) !== _selector
) {
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
if (context === -2) {
var parsedRules = parsingRules;
parsingRules = [];
return parsedRules;
}
};
var parseRulesPlugin = _insertRulePlugin(function (rule) {
parsingRules.push(rule);
});
stylis.use([parseRulesPlugin, returnRulesPlugin]);
stylisSplitter.use([parseRulesPlugin, returnRulesPlugin]);
var stringifyRules = function stringifyRules(rules, selector, prefix) {
var flatCSS = rules.join('').replace(COMMENT_REGEX, ''); // replace JS comments
var cssStr = selector && prefix ? prefix + ' ' + selector + ' { ' + flatCSS + ' }' : flatCSS;
return stylis(prefix || !selector ? '' : selector, cssStr);
};
var splitByRules = function splitByRules(css) {
return stylisSplitter('', css);
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
if (context === -2) {
var parsedRules = parsingRules;
parsingRules = [];
return parsedRules;
}
};
var parseRulesPlugin = _insertRulePlugin(function(rule) {
parsingRules.push(rule);
});
var _componentId = void 0;
var _selector = void 0;
var _selectorRegexp = void 0;
var selfReferenceReplacer = function selfReferenceReplacer(match, offset, string) {
if (
// the first self-ref is always untouched
offset > 0 &&
// there should be at least two self-refs to do a replacement (.b > .b)
string.slice(0, offset).indexOf(_selector) !== -1 &&
// no consecutive self refs (.b.b); that is a precedence boost and treated differently
string.slice(offset - _selector.length, offset) !== _selector
) {
// Wrap `insertRulePlugin to build a list of rules,
// and then make our own plugin to return the rules. This
// makes it easier to hook into the existing SSR architecture
var parsingRules = [];
// eslint-disable-next-line consistent-return
var returnRulesPlugin = function returnRulesPlugin(context) {
if (context === -2) {
var parsedRules = parsingRules;
parsingRules = [];
return parsedRules;
}
};
var parseRulesPlugin = _insertRulePlugin(function (rule) {
parsingRules.push(rule);
});
stylis.use([parseRulesPlugin, returnRulesPlugin]);
stylisSplitter.use([parseRulesPlugin, returnRulesPlugin]);
var stringifyRules = function stringifyRules(rules, selector, prefix) {
var flatCSS = rules.join('').replace(COMMENT_REGEX, ''); // replace JS comments
var cssStr = selector && prefix ? prefix + ' ' + selector + ' { ' + flatCSS + ' }' : flatCSS;
return stylis(prefix || !selector ? '' : selector, cssStr);
};
var splitByRules = function splitByRules(css) {
return stylisSplitter('', css);
newTest(spec.name, () => {
let out = []
const plugin = stylisRuleSheet(rule => {
out.push(rule)
})
stylis.use(null)(plugin)
stylis(`.css-${i}`, spec.sample)
expect(out).toMatchSnapshot()
expect(out.join('')).toEqual(regularStylis(`.css-${i}`, spec.sample))
})
})
newTest(spec.name, () => {
let out = []
const plugin = stylisRuleSheet(rule => {
out.push(rule)
})
let selector = spec.expected ? '.user' : `.css-${i}`
stylis.use(null)(plugin)
stylis(selector, spec.sample)
if (spec.expected) {
expect(out.join('')).toEqual(spec.expected)
} else {
expect(out).toMatchSnapshot()
}
expect(out.join('')).toEqual(regularStylis(selector, spec.sample))
})
})