UNPKG

stylis-plugin-extra-class-names-specifity

Version:
33 lines (26 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var stylisPluginExtraClassNamesSpecifity = function stylisPluginExtraClassNamesSpecifity() { for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) { rest[_key] = arguments[_key]; } return function (element) { var _element$root; var specificity = rest.map(function (value) { return value || 1; }); // we only want type "rule" and no keyframes definitions if (element.type !== "rule" || ((_element$root = element.root) === null || _element$root === void 0 ? void 0 : _element$root.type) === "@keyframes") { return; } if (element.parent === null && specificity && specificity > 1) { element.props = element.props.map(function (prop) { return /^\.[\w\d-_]+$/i.test(prop) ? prop.repeat(specificity) : prop; }); } }; }; var _default = stylisPluginExtraClassNamesSpecifity; exports["default"] = _default;