🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-prefix-selector

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-prefix-selector - npm Package Compare versions

Comparing version

to
2.0.0

94

index.js

@@ -1,2 +0,2 @@

module.exports = function postcssPrefixSelector(options) {
const prefixPlugin = (options = {}) => {
const prefix = options.prefix;

@@ -9,52 +9,52 @@ const prefixWithSpace = /\s+$/.test(prefix) ? prefix : `${prefix} `;

return function (root) {
if (
ignoreFiles.length &&
root.source.input.file &&
isFileInArray(root.source.input.file, ignoreFiles)
) {
return;
}
if (
includeFiles.length &&
root.source.input.file &&
!isFileInArray(root.source.input.file, includeFiles)
) {
return;
}
return {
postcssPlugin: 'postcss-prefix-selector',
prepare(result) {
const root = result.root;
const file = root.source.input.file;
root.walkRules((rule) => {
const keyframeRules = [
'keyframes',
'-webkit-keyframes',
'-moz-keyframes',
'-o-keyframes',
'-ms-keyframes',
];
if (rule.parent && keyframeRules.includes(rule.parent.name)) {
// Skip ignored or non included files
if (ignoreFiles.length && file && isFileInArray(file, ignoreFiles)) {
return;
} else if (includeFiles.length && file && !isFileInArray(file, includeFiles)) {
return;
}
rule.selectors = rule.selectors.map((selector) => {
if (options.exclude && excludeSelector(selector, options.exclude)) {
return selector;
}
return {
Rule(rule, { result }) {
const keyframeRules = [
'keyframes',
'-webkit-keyframes',
'-moz-keyframes',
'-o-keyframes',
'-ms-keyframes',
];
if (options.transform) {
return options.transform(
prefix,
selector,
prefixWithSpace + selector,
root.source.input.file,
rule
);
if (rule.parent && keyframeRules.includes(rule.parent.name)) {
return;
}
rule.selectors = rule.selectors.map((selector) => {
if (options.exclude && excludeSelector(selector, options.exclude)) {
return selector;
}
if (options.transform) {
return options.transform(
prefix,
selector,
prefixWithSpace + selector,
root.source.input.file,
rule
);
}
return prefixWithSpace + selector;
});
}
};
}
}
}
return prefixWithSpace + selector;
});
});
};
};
function isFileInArray(file, arr) {

@@ -78,2 +78,6 @@ return arr.some((ruleOrString) => {

});
}
};
prefixPlugin.postcss = true
module.exports = prefixPlugin;
{
"name": "postcss-prefix-selector",
"description": "Prefix all CSS rules with a selector",
"version": "1.16.1",
"version": "2.0.0",
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",

@@ -10,8 +10,8 @@ "contributors": [

"license": "MIT",
"repository": "RadValentin/postcss-prefix-selector",
"repository": {
"type": "git",
"url": "git+https://github.com/RadValentin/postcss-prefix-selector.git"
},
"bugs": "https://github.com/RadValentin/postcss-prefix-selector/issues",
"homepage": "https://github.com/RadValentin/postcss-prefix-selector",
"peerDependencies": {
"postcss": ">4 <9"
},
"devDependencies": {

@@ -26,2 +26,5 @@ "husky": "^8.0.3",

},
"peerDependencies": {
"postcss": "^8.0.0"
},
"scripts": {

@@ -28,0 +31,0 @@ "test": "mocha",