-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow selectors replacements and disallow with . or #
- Loading branch information
Showing
4 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import replaceValueSymbols from './replaceValueSymbols.js' | ||
import replaceValueSymbols from "./replaceValueSymbols.js"; | ||
|
||
const replaceSymbols = (css, replacements) => { | ||
css.walkDecls( | ||
decl => (decl.value = replaceValueSymbols(decl.value, replacements)) | ||
) | ||
css.walkAtRules( | ||
'media', | ||
atRule => (atRule.params = replaceValueSymbols(atRule.params, replacements)) | ||
) | ||
} | ||
css.walk(node => { | ||
if (node.type === "decl") { | ||
node.value = replaceValueSymbols(node.value, replacements); | ||
} else if (node.type === "rule") { | ||
node.selector = replaceValueSymbols(node.selector, replacements); | ||
} else if (node.type === "atrule" && node.name === "media") { | ||
node.params = replaceValueSymbols(node.params, replacements); | ||
} | ||
}); | ||
}; | ||
|
||
export default replaceSymbols | ||
export default replaceSymbols; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters