You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
882 B

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: ()=>_default
  8. });
  9. const _postcssSelectorParser = /*#__PURE__*/ _interopRequireDefault(require("postcss-selector-parser"));
  10. function _interopRequireDefault(obj) {
  11. return obj && obj.__esModule ? obj : {
  12. default: obj
  13. };
  14. }
  15. function _default(prefix, selector, prependNegative = false) {
  16. return (0, _postcssSelectorParser.default)((selectors)=>{
  17. selectors.walkClasses((classSelector)=>{
  18. let baseClass = classSelector.value;
  19. let shouldPlaceNegativeBeforePrefix = prependNegative && baseClass.startsWith("-");
  20. classSelector.value = shouldPlaceNegativeBeforePrefix ? `-${prefix}${baseClass.slice(1)}` : `${prefix}${baseClass}`;
  21. });
  22. }).processSync(selector);
  23. }