Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
885 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
---|
4 |
|
---|
5 | var postcss = _interopDefault(require('postcss'));
|
---|
6 |
|
---|
7 | const selectorRegExp = /:focus-within([^\w-]|$)/gi;
|
---|
8 | var index = postcss.plugin('postcss-focus-within', opts => {
|
---|
9 | const replaceWith = String(Object(opts).replaceWith || '[focus-within]');
|
---|
10 | const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
|
---|
11 | return root => {
|
---|
12 | root.walkRules(selectorRegExp, rule => {
|
---|
13 | const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
|
---|
14 | return `${replaceWith}${$1}`;
|
---|
15 | });
|
---|
16 | const clone = rule.clone({
|
---|
17 | selector
|
---|
18 | });
|
---|
19 |
|
---|
20 | if (preserve) {
|
---|
21 | rule.before(clone);
|
---|
22 | } else {
|
---|
23 | rule.replaceWith(clone);
|
---|
24 | }
|
---|
25 | });
|
---|
26 | };
|
---|
27 | });
|
---|
28 |
|
---|
29 | module.exports = index;
|
---|
30 | //# sourceMappingURL=index.cjs.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.