index.es.mjs 734 B

1234567891011121314151617181920212223242526
  1. import postcss from 'postcss';
  2. const selectorRegExp = /:focus-visible([^\w-]|$)/gi;
  3. var index = postcss.plugin('postcss-focus-visible', opts => {
  4. const replaceWith = String(Object(opts).replaceWith || '.focus-visible');
  5. const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
  6. return root => {
  7. root.walkRules(selectorRegExp, rule => {
  8. const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
  9. return `${replaceWith}${$1}`;
  10. });
  11. const clone = rule.clone({
  12. selector
  13. });
  14. if (preserve) {
  15. rule.before(clone);
  16. } else {
  17. rule.replaceWith(clone);
  18. }
  19. });
  20. };
  21. });
  22. export default index;
  23. //# sourceMappingURL=index.es.mjs.map