postcss-unwrap-mq
Advanced tools
Comparing version
30
index.js
@@ -1,24 +0,28 @@ | ||
let postcss = require('postcss') | ||
module.exports = postcss.plugin('postcss-unwrap-mq', (opts = { }) => { | ||
module.exports = (opts = {}) => { | ||
// eslint-disable-next-line prefer-let/prefer-let | ||
const { | ||
regex | ||
regex = undefined | ||
} = opts | ||
return (root, result) => { | ||
if (!regex) { | ||
return | ||
if (!regex) { | ||
return { | ||
postcssPlugin: 'postcss-unwrap-mq', | ||
} | ||
} | ||
root.walkAtRules('media', atrule => { | ||
const test = new RegExp(regex) | ||
const matched = test.test(atrule.params) | ||
return { | ||
postcssPlugin: 'postcss-unwrap-mq', | ||
AtRule(atrule) { | ||
// eslint-disable-next-line security/detect-non-literal-regexp | ||
let test = new RegExp(regex) | ||
let matched = test.test(atrule.params) | ||
if (matched) { | ||
atrule.walkRules(rule => { | ||
root.insertBefore(atrule, rule) | ||
atrule.parent.insertBefore(atrule, rule) | ||
}) | ||
atrule.remove() | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
} | ||
module.exports.postcss = true |
{ | ||
"name": "postcss-unwrap-mq", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "PostCSS plugin to extract matched media queries to their parents", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26
23.81%0
-100%3758
-32.46%5
-54.55%