Skip to content

Commit

Permalink
fix(): v1.2.1修复出现多余的非主题样式
Browse files Browse the repository at this point in the history
  • Loading branch information
GitOfZGT committed Sep 4, 2021
1 parent 3817db7 commit 391b722
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zougt/some-loader-utils",
"version": "1.2.0",
"version": "1.2.1",
"description": "implementation for less-loader or sass-loader. Compiles Less or sass to CSS.",
"license": "MIT",
"repository": "GitOfZGT/some-loader-utils",
Expand Down
36 changes: 12 additions & 24 deletions src/postcss-addScopeName.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,18 @@ export default (
themeRule.type === 'rule' &&
themeRule.selector === rule.selector
) {
let childNodes = [];
rule.nodes.forEach((cn) => {
if (cn.type === 'decl') {
// 过滤出样式属性相同,值不同的节点
const decls = themeRule.nodes.filter((ccn) => {
if (ccn.type !== 'decl') {
return false;
}

if (
ccn.prop === cn.prop &&
ccn.value !== cn.value
) {
currentThemeProps[cn.prop] = cn.value;
return true;
}

return false;
});

childNodes = childNodes.concat(decls);
decls.forEach((n) => {
themeRule.removeChild(n);
});
const childNodes = [];
rule.nodes.forEach((cn, cindex) => {
// 过滤出样式属性相同,值不同的节点
const themeNode = themeRule.nodes[cindex];
if (
themeNode.type === 'decl' &&
cn.type === 'decl' &&
themeNode.prop === cn.prop &&
themeNode.value !== cn.value
) {
childNodes.push(themeNode);
currentThemeProps[cn.prop] = cn.value;
}
});

Expand Down

0 comments on commit 391b722

Please sign in to comment.