postcss-pseudo-class-any-link
Advanced tools
Comparing version 1.0.0 to 3.0.0
@@ -1,3 +0,9 @@ | ||
## 1.0.0 (2015-09-01) | ||
# Changes to :any-link | ||
### 3.0.0 (December 5, 2016) | ||
- Updated: boilerplate conventions (Node v6.9.1 LTS) | ||
### 1.0.0 (September 1, 2015) | ||
- Updated: PostCSS 5 | ||
@@ -7,3 +13,3 @@ - Updated: Develop dependencies | ||
## 0.3.0 (2015-06-16) | ||
### 0.3.0 (June 16, 2015) | ||
@@ -14,12 +20,12 @@ - Added: Support for complex uses | ||
## 0.2.1 (2015-06-16) | ||
### 0.2.1 (June 16, 2015) | ||
- Fixed: postcss-selector-parser is included as a dependency | ||
## 0.2.0 (2015-06-15) | ||
### 0.2.0 (June 15, 2015) | ||
- Changed: use postcss-selector-parser | ||
## 0.1.1 (2015-06-14) | ||
### 0.1.1 (June 14, 2015) | ||
Initial release |
49
index.js
@@ -1,22 +0,39 @@ | ||
var postcss = require('postcss'); | ||
var postcssSelectorParser = require('postcss-selector-parser'); | ||
// tooling | ||
const postcss = require('postcss'); | ||
const parser = require('postcss-selector-parser'); | ||
module.exports = postcss.plugin('postcss-pseudo-class-any-link', function (opts) { | ||
// cache the any-link value | ||
var valueAnyLink = ':' + (opts && opts.prefix ? '-' + opts.prefix + '-' : '') + 'any-link'; | ||
// plugin | ||
module.exports = postcss.plugin('postcss-pseudo-class-any-link', ({ | ||
prefix = '' | ||
}) => { | ||
// dashed prefix | ||
const dashedPrefix = prefix ? '-' + prefix + '-' : ''; | ||
return function (css) { | ||
// any-link value | ||
const anyLinkValue = `:${ dashedPrefix }any-link`; | ||
// selector pattern | ||
const selectorMatch = new RegExp(`${ dashedPrefix }any-link`); | ||
return (css) => { | ||
// for each rule | ||
css.walkRules(function (rule) { | ||
css.walkRules(selectorMatch, (rule) => { | ||
const rawSelector = rule.raws.selector && rule.raws.selector.raw || rule.selector; | ||
// workaround for https://github.com/postcss/postcss-selector-parser/issues/28#issuecomment-171910556 | ||
if (rawSelector[rawSelector.length - 1] === ':') { | ||
return; | ||
} | ||
// update the selector | ||
rule.selector = postcssSelectorParser(function (selectors) { | ||
rule.selector = parser((selectors) => { | ||
// cache variables | ||
var node; | ||
var nodeIndex; | ||
var selector; | ||
var selectorLink; | ||
var selectorVisited; | ||
let node; | ||
let nodeIndex; | ||
let selector; | ||
let selectorLink; | ||
let selectorVisited; | ||
// cache the selector index | ||
var selectorIndex = -1; | ||
let selectorIndex = -1; | ||
@@ -31,3 +48,3 @@ // for each selector | ||
// if the node value matches the any-link value | ||
if (node.value === valueAnyLink) { | ||
if (node.value === anyLinkValue) { | ||
// clone the selector | ||
@@ -49,5 +66,5 @@ selectorLink = selector.clone(); | ||
} | ||
}).process(rule.selector).result; | ||
}).process(rawSelector).result; | ||
}); | ||
}; | ||
}); |
107
LICENSE.md
@@ -1,15 +0,106 @@ | ||
# CC0 1.0 Universal License | ||
# CC0 1.0 Universal | ||
Public Domain Dedication | ||
## Statement of Purpose | ||
The person(s) who associated a work with this deed has dedicated the work to the public domain by waiving all of his or her rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. | ||
The laws of most jurisdictions throughout the world automatically confer | ||
exclusive Copyright and Related Rights (defined below) upon the creator and | ||
subsequent owner(s) (each and all, an “owner”) of an original work of | ||
authorship and/or a database (each, a “Work”). | ||
You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. | ||
Certain owners wish to permanently relinquish those rights to a Work for the | ||
purpose of contributing to a commons of creative, cultural and scientific works | ||
(“Commons”) that the public can reliably and without fear of later claims of | ||
infringement build upon, modify, incorporate in other works, reuse and | ||
redistribute as freely as possible in any form whatsoever and for any purposes, | ||
including without limitation commercial purposes. These owners may contribute | ||
to the Commons to promote the ideal of a free culture and the further | ||
production of creative, cultural and scientific works, or to gain reputation or | ||
greater distribution for their Work in part through the use and efforts of | ||
others. | ||
In no way are the patent or trademark rights of any person affected by CC0, nor are the rights that other persons may have in the work or in how the work is used, such as publicity or privacy rights. | ||
For these and/or other purposes and motivations, and without any expectation of | ||
additional consideration or compensation, the person associating CC0 with a | ||
Work (the “Affirmer”), to the extent that he or she is an owner of Copyright | ||
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and | ||
publicly distribute the Work under its terms, with knowledge of his or her | ||
Copyright and Related Rights in the Work and the meaning and intended legal | ||
effect of CC0 on those rights. | ||
Unless expressly stated otherwise, the person(s) who associated a work with this deed makes no warranties about the work, and disclaims liability for all uses of the work, to the fullest extent permitted by applicable law. | ||
1. Copyright and Related Rights. A Work made available under CC0 may be | ||
protected by copyright and related or neighboring rights (“Copyright and | ||
Related Rights”). Copyright and Related Rights include, but are not limited | ||
to, the following: | ||
1. the right to reproduce, adapt, distribute, perform, display, | ||
communicate, and translate a Work; | ||
2. moral rights retained by the original author(s) and/or performer(s); | ||
3. publicity and privacy rights pertaining to a person’s image or likeness | ||
depicted in a Work; | ||
4. rights protecting against unfair competition in regards to a Work, | ||
subject to the limitations in paragraph 4(i), below; | ||
5. rights protecting the extraction, dissemination, use and reuse of data | ||
in a Work; | ||
6. database rights (such as those arising under Directive 96/9/EC of the | ||
European Parliament and of the Council of 11 March 1996 on the legal | ||
protection of databases, and under any national implementation thereof, | ||
including any amended or successor version of such directive); and | ||
7. other similar, equivalent or corresponding rights throughout the world | ||
based on applicable law or treaty, and any national implementations | ||
thereof. | ||
When using or citing the work, you should not imply endorsement by the author or the affirmer. | ||
2. Waiver. To the greatest extent permitted by, but not in contravention of, | ||
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and | ||
unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright | ||
and Related Rights and associated claims and causes of action, whether now | ||
known or unknown (including existing as well as future claims and causes of | ||
action), in the Work (i) in all territories worldwide, (ii) for the maximum | ||
duration provided by applicable law or treaty (including future time | ||
extensions), (iii) in any current or future medium and for any number of | ||
copies, and (iv) for any purpose whatsoever, including without limitation | ||
commercial, advertising or promotional purposes (the “Waiver”). Affirmer makes | ||
the Waiver for the benefit of each member of the public at large and to the | ||
detriment of Affirmer’s heirs and successors, fully intending that such Waiver | ||
shall not be subject to revocation, rescission, cancellation, termination, or | ||
any other legal or equitable action to disrupt the quiet enjoyment of the Work | ||
by the public as contemplated by Affirmer’s express Statement of Purpose. | ||
This is a [human-readable summary of the Legal Code](https://creativecommons.org/publicdomain/zero/1.0/) ([read the full text](https://creativecommons.org/publicdomain/zero/1.0/legalcode)). | ||
3. Public License Fallback. Should any part of the Waiver for any reason be | ||
judged legally invalid or ineffective under applicable law, then the Waiver | ||
shall be preserved to the maximum extent permitted taking into account | ||
Affirmer’s express Statement of Purpose. In addition, to the extent the Waiver | ||
is so judged Affirmer hereby grants to each affected person a royalty-free, non | ||
transferable, non sublicensable, non exclusive, irrevocable and unconditional | ||
license to exercise Affirmer’s Copyright and Related Rights in the Work (i) in | ||
all territories worldwide, (ii) for the maximum duration provided by applicable | ||
law or treaty (including future time extensions), (iii) in any current or | ||
future medium and for any number of copies, and (iv) for any purpose | ||
whatsoever, including without limitation commercial, advertising or promotional | ||
purposes (the “License”). The License shall be deemed effective as of the date | ||
CC0 was applied by Affirmer to the Work. Should any part of the License for any | ||
reason be judged legally invalid or ineffective under applicable law, such | ||
partial invalidity or ineffectiveness shall not invalidate the remainder of the | ||
License, and in such case Affirmer hereby affirms that he or she will not (i) | ||
exercise any of his or her remaining Copyright and Related Rights in the Work | ||
or (ii) assert any associated claims and causes of action with respect to the | ||
Work, in either case contrary to Affirmer’s express Statement of Purpose. | ||
4. Limitations and Disclaimers. | ||
1. No trademark or patent rights held by Affirmer are waived, abandoned, | ||
surrendered, licensed or otherwise affected by this document. | ||
2. Affirmer offers the Work as-is and makes no representations or | ||
warranties of any kind concerning the Work, express, implied, statutory | ||
or otherwise, including without limitation warranties of title, | ||
merchantability, fitness for a particular purpose, non infringement, or | ||
the absence of latent or other defects, accuracy, or the present or | ||
absence of errors, whether or not discoverable, all to the greatest | ||
extent permissible under applicable law. | ||
3. Affirmer disclaims responsibility for clearing rights of other persons | ||
that may apply to the Work or any use thereof, including without | ||
limitation any person’s Copyright and Related Rights in the Work. | ||
Further, Affirmer disclaims responsibility for obtaining any necessary | ||
consents, permissions or other rights required for any use of the Work. | ||
4. Affirmer understands and acknowledges that Creative Commons is not a | ||
party to this document and has no duty or obligation with respect to | ||
this CC0 or use of the Work. | ||
For more information, please see | ||
http://creativecommons.org/publicdomain/zero/1.0/. |
{ | ||
"name": "postcss-pseudo-class-any-link", | ||
"version": "1.0.0", | ||
"description": "Use the proposed :any-link pseudo-class in CSS", | ||
"keywords": ["postcss", "css", "postcss-plugin", "link", "visited", "any-link", "a", "area", "hyperlink", "href"], | ||
"author": "Jonathan Neal <jonathantneal@hotmail.com>", | ||
"license": "CC0-1.0", | ||
"bugs": { | ||
"url": "https://github.com/jonathantneal/postcss-pseudo-class-any-link/issues" | ||
}, | ||
"homepage": "https://github.com/jonathantneal/postcss-pseudo-class-any-link", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jonathantneal/postcss-pseudo-class-any-link.git" | ||
}, | ||
"dependencies": { | ||
"postcss": "^5.0.3", | ||
"postcss-selector-parser": "^1.1.4" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.2.0", | ||
"gulp": "^3.9.0", | ||
"gulp-eslint": "^1.0.0", | ||
"gulp-mocha": "^2.1.3" | ||
}, | ||
"scripts": { | ||
"test": "gulp" | ||
} | ||
"name": "postcss-pseudo-class-any-link", | ||
"version": "3.0.0", | ||
"description": "Use the proposed :any-link pseudo-class in CSS", | ||
"author": "Jonathan Neal <jonathantneal@hotmail.com>", | ||
"license": "CC0-1.0", | ||
"repository": "jonathantneal/postcss-pseudo-class-any-link", | ||
"homepage": "https://github.com/jonathantneal/postcss-pseudo-class-any-link#readme", | ||
"bugs": "https://github.com/jonathantneal/postcss-pseudo-class-any-link/issues", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"lint": "echint && eslint index.js && jscs index.js", | ||
"prepublish": "npm test", | ||
"tape": "postcss-tape", | ||
"test": "npm run lint && postcss-tape" | ||
}, | ||
"engines": { | ||
"node": ">=6.9.1" | ||
}, | ||
"dependencies": { | ||
"postcss": "^5.2.6", | ||
"postcss-selector-parser": "^2.2.2" | ||
}, | ||
"devDependencies": { | ||
"echint": "^2.1.0", | ||
"echint-config-dev": "1.0.0", | ||
"eslint": "^3.11.1", | ||
"eslint-config-dev": "1.0.0", | ||
"jscs": "^3.0.7", | ||
"jscs-config-dev": "1.0.1", | ||
"postcss-tape": "1.0.1" | ||
}, | ||
"echint": { | ||
"extends": "dev" | ||
}, | ||
"eslintConfig": { | ||
"extends": "dev", | ||
"parserOptions": { | ||
"sourceType": "module" | ||
} | ||
}, | ||
"jscsConfig": { | ||
"preset": "dev" | ||
}, | ||
"keywords": [ | ||
"postcss", | ||
"css", | ||
"postcss-plugin", | ||
"link", | ||
"visited", | ||
"any-link", | ||
"a", | ||
"area", | ||
"hyperlink", | ||
"href" | ||
] | ||
} |
115
README.md
@@ -1,6 +0,10 @@ | ||
# PostCSS Pseudo-Class Any-Link [![Build Status][ci-img]][ci] | ||
# :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> | ||
<img align="right" width="135" height="95" src="http://postcss.github.io/postcss/logo-leftp.png" title="Philosopher’s stone, logo of 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] | ||
[PostCSS Pseudo-Class Any-Link] is a [PostCSS] plugin that allows you to use the proposed [`:any-link`] pseudo-class in CSS. | ||
[:any-link] lets you to use the proposed [`:any-link`] pseudo-class in CSS. | ||
@@ -28,28 +32,75 @@ `:any-link` simplifies selectors targeting links, as the naming of `:link` is misleading; it specifically means unvisited links only, rather than all links. | ||
## 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 | ||
You just need to follow these two steps to use [PostCSS Pseudo-Class Any-Link]: | ||
Add [:any-link] to your build tool: | ||
1. Add [PostCSS] to your build tool. | ||
2. Add [PostCSS Pseudo-Class Any-Link] as a PostCSS process. | ||
```bash | ||
npm install :any-link --save-dev | ||
``` | ||
```sh | ||
npm install postcss-pseudo-class-any-link --save-dev | ||
#### Node | ||
```js | ||
require(':any-link').process(YOUR_CSS, { /* options */ }); | ||
``` | ||
### Node | ||
#### PostCSS | ||
Add [PostCSS] to your build tool: | ||
```bash | ||
npm install postcss --save-dev | ||
``` | ||
Load [:any-link] as a PostCSS plugin: | ||
```js | ||
postcss([ require('postcss-pseudo-class-any-link')({ /* options */ }) ]) | ||
postcss([ | ||
require(':any-link')({ /* options */ }) | ||
]).process(YOUR_CSS, /* options */); | ||
``` | ||
### Grunt | ||
#### Gulp | ||
Add [Gulp PostCSS] to your build tool: | ||
```bash | ||
npm install gulp-postcss --save-dev | ||
``` | ||
Enable [:any-link] within your Gulpfile: | ||
```js | ||
var postcss = require('gulp-postcss'); | ||
gulp.task('css', function () { | ||
return gulp.src('./src/*.css').pipe( | ||
postcss([ | ||
require(':any-link')({ /* options */ }) | ||
]) | ||
).pipe( | ||
gulp.dest('.') | ||
); | ||
}); | ||
``` | ||
#### Grunt | ||
Add [Grunt PostCSS] to your build tool: | ||
```sh | ||
npm install postcss-pseudo-class-any-link --save-dev | ||
```bash | ||
npm install grunt-postcss --save-dev | ||
``` | ||
Enable [PostCSS Pseudo-Class Any-Link] within your Gruntfile: | ||
Enable [:any-link] within your Gruntfile: | ||
@@ -62,8 +113,8 @@ ```js | ||
options: { | ||
processors: [ | ||
require('postcss-pseudo-class-any-link')({ /* options */ }) | ||
use: [ | ||
require(':any-link')({ /* options */ }) | ||
] | ||
}, | ||
dist: { | ||
src: 'css/*.css' | ||
src: '*.css' | ||
} | ||
@@ -74,12 +125,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 | ||
} | ||
``` | ||
### Alternatives | ||
@@ -105,10 +146,20 @@ | ||
[npm-url]: https://www.npmjs.com/package/postcss-pseudo-class-any-link | ||
[npm-img]: https://img.shields.io/npm/v/postcss-pseudo-class-any-link.svg | ||
[cli-url]: https://travis-ci.org/jonathantneal/postcss-pseudo-class-any-link | ||
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-pseudo-class-any-link.svg | ||
[lic-url]: LICENSE.md | ||
[lic-image]: 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 | ||
[git-url]: https://gitter.im/postcss/postcss | ||
[git-image]: https://img.shields.io/badge/chat-gitter-blue.svg | ||
[:any-link]: https://github.com/jonathantneal/postcss-pseudo-class-any-link | ||
[`:any-link`]: http://dev.w3.org/csswg/selectors/#any-link-pseudo | ||
[`:link`]: http://dev.w3.org/csswg/selectors/#link-pseudo | ||
[`:visited`]: http://dev.w3.org/csswg/selectors/#visited-pseudo | ||
[ci]: https://travis-ci.org/jonathantneal/postcss-pseudo-class-any-link | ||
[ci-img]: https://travis-ci.org/jonathantneal/postcss-pseudo-class-any-link.svg | ||
[proposal]: http://dev.w3.org/csswg/selectors/ | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss | ||
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss | ||
[PostCSS]: https://github.com/postcss/postcss | ||
[PostCSS Pseudo-Class Any-Link]: https://github.com/jonathantneal/postcss-pseudo-class-any-link | ||
[proposal]: http://dev.w3.org/csswg/selectors/ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
14220
0
100
56
162
7
5
1
1
+ Addedpostcss-selector-parser@2.2.3(transitive)
- Removedpostcss-selector-parser@1.3.3(transitive)
Updatedpostcss@^5.2.6