Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-atroot

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-atroot - npm Package Compare versions

Comparing version 0.1.3 to 0.2.3

.github/workflows/nodejs.yml

29

index.js

@@ -1,14 +0,19 @@

var postcss = require('postcss')
module.exports = () => {
return {
postcssPlugin: 'postcss-atroot',
AtRule: {
'at-root': function (rule) {
// Find first node from root to move child nodes after it
let p = rule
while (p && p.parent && p.parent.type !== 'root') {
p = p.parent
}
module.exports = postcss.plugin('postcss-atroot', function (opts) {
opts = opts || {}
return function (root, opts) {
root.walkAtRules('at-root', function (rule) {
var p = rule
// Find first node from root to move child nodes after it
while (p && p.parent !== root) p = p.parent
root.insertBefore(p, rule.nodes)
rule.remove()
})
rule.root().insertBefore(p, rule.nodes)
rule.remove()
}
}
}
})
}
module.exports.postcss = true
{
"name": "postcss-atroot",
"version": "0.1.3",
"version": "0.2.3",
"description": "PostCSS plugin to place rules directly at the root",

@@ -11,4 +11,4 @@ "main": "index.js",

"scripts": {
"start": "gulp",
"test": "gulp"
"pretest": "eslint index.js test",
"test": "mocha test/*.js"
},

@@ -25,12 +25,14 @@ "keywords": [

"license": "MIT",
"dependencies": {
"postcss": "^5.0.5"
"engines": {
"node": ">= 10"
},
"devDependencies": {
"chai": "^3.2.0",
"gulp": "^3.9.0",
"gulp-eslint": "^1.0.0",
"gulp-mocha": "^2.1.3",
"mocha": "^2.3.2"
"chai": "^4.3.4",
"eslint": "^7.26.0",
"mocha": "^8.4.0",
"postcss": "^8.2.15"
},
"peerDependencies": {
"postcss": "^8.2.15"
}
}

@@ -5,3 +5,3 @@ var postcss = require('postcss')

var test = function (input, output, opts) {
function test (input, output, opts) {
var result = postcss(atroot(opts)).process(input)

@@ -14,13 +14,29 @@ expect(result.css).to.eql(output)

describe('postcss-atroot', function () {
it('places nodes before parent rule', function () {
test('.test {@at-root {.root {color: black}}}',
'.root {\n color: black\n}\n.test {}')
test(
'.test {@at-root {.root {color: black}}}',
'.root {color: black}.test {}'
)
})
it('places nodes before parent rule, recursively', function () {
test(
'.test { .innertest { @at-root {.root {color: black}}}}',
'.root {color: black}.test { .innertest {}}'
)
})
it('places nodes before parent rule, keeps nested media', function () {
test(
'.test { .innertest { @at-root { @media(print) {.root {color: black}}}}}',
' @media(print) {.root {color: black}} .test { .innertest {}}'
)
})
it('saves nodes order', function () {
test('.test {@at-root {color: white;color: black;color: green}}',
'color: white;\ncolor: black;\ncolor: green;\n.test {}')
test(
'.test {@at-root {color: white;color: black;color: green}}',
'color: white;color: black;color: green;\n.test {}'
)
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc