New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

postcss-focus

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-focus - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

4

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 4.0
* Use PostCSS 7.
* Remove Node.js 4 support.
## 3.0

@@ -5,0 +9,0 @@ * Do not process if there is a `:focus` selector already (by Vitalii Rizo).

46

index.js

@@ -1,28 +0,28 @@

var postcss = require('postcss');
var postcss = require('postcss')
function hasAlready(parent, selector) {
return parent.nodes.some(function (i) {
return i.type === 'rule' && i.selectors.indexOf(selector) !== -1;
});
function hasAlready (parent, selector) {
return parent.nodes.some(function (i) {
return i.type === 'rule' && i.selectors.indexOf(selector) !== -1
})
}
module.exports = postcss.plugin('postcss-focus', function () {
return function (css) {
css.walkRules(function (rule) {
if ( rule.selector.indexOf(':hover') !== -1 ) {
var focuses = [];
rule.selectors.forEach(function (selector) {
if ( selector.indexOf(':hover') !== -1 ) {
var replaced = selector.replace(/:hover/g, ':focus');
if ( !hasAlready(rule.parent, replaced) ) {
focuses.push(replaced);
}
}
});
if ( focuses.length ) {
rule.selectors = rule.selectors.concat(focuses);
}
return function (css) {
css.walkRules(function (rule) {
if (rule.selector.indexOf(':hover') !== -1) {
var focuses = []
rule.selectors.forEach(function (selector) {
if (selector.indexOf(':hover') !== -1) {
var replaced = selector.replace(/:hover/g, ':focus')
if (!hasAlready(rule.parent, replaced)) {
focuses.push(replaced)
}
});
};
});
}
})
if (focuses.length) {
rule.selectors = rule.selectors.concat(focuses)
}
}
})
}
})
{
"name": "postcss-focus",
"version": "3.0.0",
"version": "4.0.0",
"description": "PostCSS plugin to add :focus selector to every :hover for keyboard accessibility",

@@ -23,34 +23,4 @@ "keywords": [

"dependencies": {
"postcss": "^6.0.13"
},
"devDependencies": {
"eslint": "^4.8.0",
"eslint-config-postcss": "^2.0.2",
"jest": "^21.2.1",
"lint-staged": "^4.2.3",
"pre-commit": "^1.2.2"
},
"scripts": {
"lint-staged": "lint-staged",
"test": "jest --coverage && eslint *.js"
},
"jest": {
"coverageThreshold": {
"global": {
"statements": 100
}
}
},
"eslintConfig": {
"extends": "eslint-config-postcss/es5",
"env": {
"jest": true
}
},
"lint-staged": {
"*.js": "eslint"
},
"pre-commit": [
"lint-staged"
]
"postcss": "^7.0.2"
}
}
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