Skip to content

Commit

Permalink
fix(postcss-prefix-selector): keep only prefix for :root selector
Browse files Browse the repository at this point in the history
  • Loading branch information
dryabinin94 committed Nov 5, 2024
1 parent 6f1e6ec commit c1c7352
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/arui-scripts/src/plugins/postcss-prefix-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type PostCssPrefixOptions = {

const VisitedRule = Symbol('VisitedRule');

const ROOT_SELECTOR = ':root';

type RootWithVisitedRule = Root & {
[VisitedRule]?: boolean;
};
Expand Down Expand Up @@ -49,7 +51,18 @@ const postCssPrefix: PluginCreator<PostCssPrefixOptions> = (options) => {
return;
}

rule.selectors = rule.selectors.map((selector) => `${prefix}${selector}`);
rule.selectors = rule.selectors.map((selector) => {
/**
* Оборачивам только самим префиксом без :root.
* Позволяет инкапсулировать css переменные под классом.
* В таком случае они будут доступны в модулях приложений после использования флага keepCssVars.
*/

Check failure on line 59 in packages/arui-scripts/src/plugins/postcss-prefix-selector.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Trailing spaces not allowed

Check failure on line 59 in packages/arui-scripts/src/plugins/postcss-prefix-selector.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Trailing spaces not allowed

Check failure on line 59 in packages/arui-scripts/src/plugins/postcss-prefix-selector.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Trailing spaces not allowed
if (selector === ROOT_SELECTOR) {
return prefix;
}

return `${prefix}${selector}`;
});
});
},
};
Expand Down

0 comments on commit c1c7352

Please sign in to comment.