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

postcss-pseudo-class-any-link

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-pseudo-class-any-link - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

6

CHANGELOG.md
# Changes to :any-link
### 4.0.0 (May 10, 2017)
- Added: Support for PostCSS v6
- Added: Support for Node v4
- Removed: `prefix` option, as that would be non-spec
### 3.0.1 (December 8, 2016)

@@ -4,0 +10,0 @@

98

index.js

@@ -0,1 +1,3 @@

'use strict';
// tooling

@@ -6,69 +8,49 @@ const postcss = require('postcss');

// plugin
module.exports = postcss.plugin('postcss-pseudo-class-any-link', ({
prefix = ''
} = {}) => {
// dashed prefix
const dashedPrefix = prefix ? `-${ prefix }-` : '';
module.exports = postcss.plugin('postcss-pseudo-class-any-link', () => (css) => {
// walk each matching rule
css.walkRules(/:any-link/, (rule) => {
const rawSelector = rule.raws.selector && rule.raws.selector.raw || rule.selector;
// any-link value
const anyLinkValue = `:${ dashedPrefix }any-link`;
// workaround for https://github.com/postcss/postcss-selector-parser/issues/28#issuecomment-171910556
if (rawSelector[rawSelector.length - 1] !== ':') {
// update the selector
rule.selector = parser((selectors) => {
// cache variables
let node;
let nodeIndex;
let selector;
let selectorLink;
let selectorVisited;
// selector matcher
const selectorMatch = new RegExp(`${ dashedPrefix }any-link`);
// cache the selector index
let selectorIndex = -1;
return (css) => {
// walk each matching rule
css.walkRules(selectorMatch, (rule) => {
const rawSelector = rule.raws.selector && rule.raws.selector.raw || rule.selector;
// for each selector
while (selector = selectors.nodes[++selectorIndex]) {
// reset the node index
nodeIndex = -1;
// workaround for https://github.com/postcss/postcss-selector-parser/issues/28#issuecomment-171910556
if (rawSelector[rawSelector.length - 1] !== ':') {
// update the selector
rule.selector = parser((selectors) => {
// cache variables
let node;
let nodeIndex;
let selector;
let selectorLink;
let selectorVisited;
// for each node
while (node = selector.nodes[++nodeIndex]) {
// if the node value matches the any-link value
if (node.value === ':any-link') {
// clone the selector
selectorLink = selector.clone();
selectorVisited = selector.clone();
// cache the selector index
let selectorIndex = -1;
// update the matching clone values
selectorLink.nodes[nodeIndex].value = ':link';
selectorVisited.nodes[nodeIndex].value = ':visited';
// for each selector
while (selector = selectors.nodes[++selectorIndex]) {
// reset the node index
nodeIndex = -1;
// replace the selector with the clones and roll back the selector index
selectors.nodes.splice(selectorIndex--, 1, selectorLink, selectorVisited);
// for each node
while (node = selector.nodes[++nodeIndex]) {
// if the node value matches the any-link value
if (node.value === anyLinkValue) {
// clone the selector
selectorLink = selector.clone();
selectorVisited = selector.clone();
// update the matching clone values
selectorLink.nodes[nodeIndex].value = ':link';
selectorVisited.nodes[nodeIndex].value = ':visited';
// replace the selector with the clones and roll back the selector index
selectors.nodes.splice(selectorIndex--, 1, selectorLink, selectorVisited);
// stop updating the selector
break;
}
// stop updating the selector
break;
}
}
}).process(rawSelector).result;
}
});
};
}
}).process(rawSelector).result;
}
});
});
// override plugin#process
module.exports.process = function (cssString, pluginOptions, processOptions) {
return postcss([
1 in arguments ? module.exports(pluginOptions) : module.exports()
]).process(cssString, processOptions);
};
{
"name": "postcss-pseudo-class-any-link",
"version": "3.0.1",
"version": "4.0.0",
"description": "Use the proposed :any-link pseudo-class in CSS",

@@ -15,26 +15,21 @@ "author": "Jonathan Neal <jonathantneal@hotmail.com>",

"scripts": {
"lint": "echint && eslint index.js && jscs index.js",
"clean": "git clean -X -d -f",
"prepublish": "npm test",
"tape": "postcss-tape",
"test": "npm run lint && postcss-tape"
"test": "echo 'Running tests...'; npm run test:js && npm run test:tape",
"test:js": "eslint *.js --cache --ignore-pattern .gitignore",
"test:tape": "postcss-tape"
},
"engines": {
"node": ">=6.9.1"
"node": ">=4.0.0"
},
"dependencies": {
"postcss": "^5.2.6",
"postcss-selector-parser": "^2.2.2"
"postcss": "^6.0.1",
"postcss-selector-parser": "^2.2.3"
},
"devDependencies": {
"echint": "^2.1.0",
"echint-config-dev": "1.0.0",
"eslint": "^3.12.1",
"eslint-config-dev": "1.0.0",
"jscs": "^3.0.7",
"jscs-config-dev": "1.0.1",
"postcss-tape": "1.3.0"
"eslint": "^3.19.0",
"eslint-config-dev": "2.0.0",
"postcss-tape": "2.0.1",
"pre-commit": "^1.2.2"
},
"echint": {
"extends": "dev"
},
"eslintConfig": {

@@ -46,5 +41,2 @@ "extends": "dev",

},
"jscsConfig": {
"preset": "dev"
},
"keywords": [

@@ -51,0 +43,0 @@ "postcss",

@@ -1,8 +0,8 @@

# :any-link <a href="https://github.com/postcss/postcss"><img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right"></a>
# :any-link [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][postcss]
[![NPM Version][npm-img]][npm-url]
[![Build Status][cli-img]][cli-url]
[![Licensing][lic-image]][lic-url]
[![Changelog][log-image]][log-url]
[![Gitter Chat][git-image]][git-url]
[![Licensing][lic-img]][lic-url]
[![Changelog][log-img]][log-url]
[![Gitter Chat][git-img]][git-url]

@@ -14,4 +14,2 @@ [:any-link] lets you to use the proposed [`:any-link`] pseudo-class in CSS.

```css
/* before */
nav :any-link > span {

@@ -21,6 +19,5 @@ background-color: yellow;

/* after */
/* becomes */
nav :link > span,
nav :visited > span {
nav :link > span, nav :visited > span {
background-color: yellow;

@@ -34,12 +31,2 @@ }

## Options
**prefix** (string): prepends a prefix (surrounded by dashes) to the pseudo-class, preventing any clash with native syntax.
```js
{
prefix: 'foo' // pseudo-class becomes :-foo-any-link
}
```
## Usage

@@ -50,3 +37,3 @@

```bash
npm install :any-link --save-dev
npm install postcss-pseudo-class-any-link --save-dev
```

@@ -56,4 +43,6 @@

Use [:any-link] to process your CSS:
```js
require(':any-link').process(YOUR_CSS, { /* options */ });
require('postcss-pseudo-class-any-link').process(YOUR_CSS);
```

@@ -69,8 +58,8 @@

Load [:any-link] as a PostCSS plugin:
Use [:any-link] as a plugin:
```js
postcss([
require(':any-link')({ /* options */ })
]).process(YOUR_CSS, /* options */);
require('postcss-pseudo-class-any-link')()
]).process(YOUR_CSS);
```

@@ -86,3 +75,3 @@

Enable [:any-link] within your Gulpfile:
Use [:any-link] in your Gulpfile:

@@ -95,3 +84,3 @@ ```js

postcss([
require(':any-link')({ /* options */ })
require('postcss-pseudo-class-any-link')()
])

@@ -112,3 +101,3 @@ ).pipe(

Enable [:any-link] within your Gruntfile:
Use [:any-link] in your Gruntfile:

@@ -122,3 +111,3 @@ ```js

use: [
require(':any-link')({ /* options */ })
require('postcss-pseudo-class-any-link')()
]

@@ -158,7 +147,7 @@ },

[lic-url]: LICENSE.md
[lic-image]: https://img.shields.io/npm/l/postcss-pseudo-class-any-link.svg
[lic-img]: https://img.shields.io/npm/l/postcss-pseudo-class-any-link.svg
[log-url]: CHANGELOG.md
[log-image]: https://img.shields.io/badge/changelog-md-blue.svg
[log-img]: https://img.shields.io/badge/changelog-md-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[git-image]: https://img.shields.io/badge/chat-gitter-blue.svg
[git-img]: https://img.shields.io/badge/chat-gitter-blue.svg

@@ -165,0 +154,0 @@ [:any-link]: https://github.com/jonathantneal/postcss-pseudo-class-any-link

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