index.cjs.js 887 B

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  3. var postcss = _interopDefault(require('postcss'));
  4. const selectorRegExp = /:focus-visible([^\w-]|$)/gi;
  5. var index = postcss.plugin('postcss-focus-visible', opts => {
  6. const replaceWith = String(Object(opts).replaceWith || '.focus-visible');
  7. const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
  8. return root => {
  9. root.walkRules(selectorRegExp, rule => {
  10. const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
  11. return `${replaceWith}${$1}`;
  12. });
  13. const clone = rule.clone({
  14. selector
  15. });
  16. if (preserve) {
  17. rule.before(clone);
  18. } else {
  19. rule.replaceWith(clone);
  20. }
  21. });
  22. };
  23. });
  24. module.exports = index;
  25. //# sourceMappingURL=index.cjs.js.map