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