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

postcss-pseudo-class-enter

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-pseudo-class-enter - npm Package Compare versions

Comparing version 3.0.1 to 5.0.0

index.js.map

7

CHANGELOG.md

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

# Changes to :enter
# Changes to PostCSS Enter Pseudo Class
### 4.0.0 (February 5, 2019)
- Support PostCSS 7
- Support Node 6
### 3.0.1 (December 8, 2016)

@@ -4,0 +9,0 @@

116

index.js

@@ -1,77 +0,59 @@

// tooling
const postcss = require('postcss');
const parser = require('postcss-selector-parser');
'use strict';
// plugin
module.exports = postcss.plugin('postcss-pseudo-class-enter', ({
outline = false,
prefix = ''
} = {}) => {
// prefixed node value
const value = `:${ prefix ? `-${ prefix }-` : '' }enter`;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
// transform :enter selector to :focus, :hover
const transform = (selectors) => {
// for each selector
for (let selector of selectors.nodes) {
// for each node
for (let node of selector.nodes) {
// if the node value matches the enter value
if (node.value === value) {
// update the matching values
node.value = ':hover';
var postcss = _interopDefault(require('postcss'));
var parser = _interopDefault(require('postcss-selector-parser'));
selectors.insertBefore(selector, selector.clone());
var index = postcss.plugin('postcss-pseudo-class-enter', opts => {
// add conditional prefix
const pseudoClass = `:${Object(opts).prefix ? `-${opts.prefix}-` : ''}enter`;
const pseudoClassRegExp = new RegExp(pseudoClass, 'i'); // add outline declaration
node.value = ':focus';
const shouldUseOutline = Object(opts).outline !== null && Object(opts).outline !== undefined;
return root => {
// transform :enter selectors to :focus and :hover
root.walkRules(pseudoClassRegExp, rule => {
const originalSelector = rule.selector;
const modifiedSelector = parser(selectors => {
transform(selectors, pseudoClass);
}).processSync(originalSelector);
// stop updating the selector
break;
}
}
}
};
if (originalSelector !== modifiedSelector) {
rule.selector = modifiedSelector;
}
return (css) => {
// walk each rule
css.walkRules((rule) => {
// parse the selector
let selector = parser(transform).process(rule.selector).result;
if (shouldUseOutline) {
// check for an existing outline declaration
const hasOutline = rule.nodes.some(decl => decl.prop === 'outline'); // if an outline declaration does not exist, prepend it
// if the selector has changed
if (selector !== rule.selector) {
// update the selector
rule.selector = selector;
if (!hasOutline) {
const outlineValue = !opts.outline || opts.outline === true ? 0 : opts.outline;
rule.prepend({
prop: 'outline',
value: outlineValue
});
}
}
});
};
});
// if an outline value has been defined
if (outline !== false) {
// define no outline
let noOutline = true;
function transform(selectors, pseudoClass) {
selectors.walk(selector => {
if (selector.type === 'pseudo' && selector.value === pseudoClass) {
// patch :hover pseudo
selector.value = ':hover';
const selectorsClone = selectors.clone().empty();
const selectorParentClone = selector.parent.clone();
selectorsClone.append(selectorParentClone);
transform(selectorsClone, pseudoClass);
selectors.insertBefore(selector, selectorParentClone); // patch :focus pseudo
// check for outline declaration
rule.walkDecls('outline', () => {
noOutline = false;
selector.value = ':focus';
}
});
}
return false;
});
// if outline declaration does not exist
if (noOutline) {
// prepend the outline declaration to the rule
rule.prepend({
prop: 'outline',
value: outline || 0
});
}
}
}
});
};
});
// override plugin#process
module.exports.process = function (cssString, pluginOptions, processOptions) {
return postcss([
0 in arguments ? module.exports(pluginOptions) : module.exports()
]).process(cssString, processOptions);
};
module.exports = index;
//# sourceMappingURL=index.js.map

@@ -30,78 +30,80 @@ # CC0 1.0 Universal

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.
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.
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.
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.
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.
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.
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-enter",
"version": "3.0.1",
"description": "Use the proposed :enter pseudo-class in CSS",
"version": "5.0.0",
"description": "Use the :enter pseudo-class in CSS",
"author": "Jonathan Neal <jonathantneal@hotmail.com>",

@@ -11,39 +11,38 @@ "license": "CC0-1.0",

"main": "index.js",
"module": "index.mjs",
"files": [
"index.js"
"index.js",
"index.js.map",
"index.mjs",
"index.mjs.map"
],
"scripts": {
"lint": "echint && eslint index.js && jscs index.js",
"prepublish": "npm test",
"tape": "postcss-tape",
"test": "npm run lint && postcss-tape"
"prepublishOnly": "npm test",
"pretest": "rollup --config .rollup.js --silent",
"test": "npm run test:js && npm run test:tape",
"test:js": "eslint src/*.js --cache --ignore-path .gitignore --quiet",
"test:tape": "postcss-tape"
},
"engines": {
"node": ">=6.9.1"
"node": ">=6.0.0"
},
"dependencies": {
"postcss": "^5.2.6",
"postcss-selector-parser": "^2.2.2"
"postcss": "^7.0.14",
"postcss-selector-parser": "^5.0.0"
},
"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"
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"babel-eslint": "^10.0.1",
"eslint": "^5.12.1",
"eslint-config-dev": "^2.0.0",
"postcss-tape": "^4.0.0",
"pre-commit": "^1.2.2",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2"
},
"echint": {
"extends": "dev"
},
"eslintConfig": {
"extends": "dev",
"parserOptions": {
"sourceType": "module"
}
"parser": "babel-eslint"
},
"jscsConfig": {
"preset": "dev"
},
"keywords": [

@@ -53,12 +52,14 @@ "postcss",

"postcss-plugin",
"hovers",
"focuses",
"pseudos",
"elements",
"keyboards",
"hover",
"focus",
"pseudo",
"element",
"keyboard",
"mouse",
"mice",
"finger",
"touch",
"pointer"
"pointer",
"accessibility"
]
}

@@ -1,25 +0,24 @@

# :enter <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>
# PostCSS Enter Pseudo Class [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" 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]
[![Support Chat][git-img]][git-url]
[:enter] lets you use the proposed [`:enter`] pseudo-class in CSS.
[PostCSS Enter Pseudo Class] lets you use the proposed [`:enter`] pseudo-class
in CSS.
`:enter` simplifies selectors targeting elements that are designated, as the naming of `:hover` is somewhat misleading; it specifically means elements designated with a pointing device, rather than any device.
`:enter` simplifies selectors targeting elements that are “designated”, as in
designated with a pointing device, rather than any device.
```css
/* before */
```pcss
nav :enter > span {
background-color: yellow;
background-color: yellow;
}
/* after */
/* becomes */
nav :hover > span,
nav :focus > span {
background-color: yellow;
background-color: yellow;
}

@@ -30,26 +29,10 @@ ```

> The [`:enter`] pseudo-class applies while the user designates an element with a keyboard, pointing device, or other form of input. It matches an element if the element would match [`:focus`] or [`:hover`].
> The [`:enter`] pseudo-class applies while the user designates an element with
> a keyboard, pointing device, or other form of input. It matches an element if
> the element would match [`:focus`] or [`:hover`].
## Options
#### `prefix`
Type: `String`
Default: `-`
Adds the prefix surrounded by dashes before the pseudo-class.
#### `outline`
Type: `String`
Default: unset
Adds an outline declaration to matching rules when an existing one does not already exist.
## Usage
Follow these steps to use [:enter].
Add [PostCSS Enter Pseudo Class] to your project:
Add [:enter] to your build tool:
```bash

@@ -59,73 +42,53 @@ npm install postcss-pseudo-class-enter --save-dev

#### Node
Use [PostCSS Enter Pseudo Class] to process your CSS:
```js
require('postcss-pseudo-class-enter')({ /* options */ }).process(YOUR_CSS);
```
const postcssPseudoClassEnter = require('postcss-pseudo-class-enter');
#### PostCSS
Add [PostCSS] to your build tool:
```bash
npm install postcss --save-dev
postcssPseudoClassEnter.process(YOUR_CSS /*, processOptions, pluginOptions */);
```
Load [:enter] as a PostCSS plugin:
Or use it as a [PostCSS] plugin:
```js
const postcss = require('postcss');
const postcssPseudoClassEnter = require('postcss-pseudo-class-enter');
postcss([
require('postcss-pseudo-class-enter')({ /* options */ })
]);
postcssPseudoClassEnter(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```
#### Gulp
[PostCSS Enter Pseudo Class] runs in all Node environments, with special
instructions for:
Add [Gulp PostCSS] to your build tool:
| [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
| --- | --- | --- | --- | --- | --- |
```bash
npm install gulp-postcss --save-dev
```
## Options
Enable [:enter] within your Gulpfile:
### prefix
The `prefix` option determines whether the `:enter` pseudo-class should use a
prefix, and what that prefix will be.
```js
var postcss = require('gulp-postcss');
gulp.task('css', function () {
return gulp.src('./css/src/*.css').pipe(
postcss([
require('postcss-pseudo-class-enter')({ /* options */ })
])
).pipe(
gulp.dest('./css')
);
});
postcssPseudoClassEnter({ prefix: 'x' }); // transforms :-x-enter
```
#### Grunt
#### outline
Add [Grunt PostCSS] to your build tool:
Type: `String`
Default: unset
```bash
npm install grunt-postcss --save-dev
The `outline` option determines whether an outline declaration will be added to
rules using the `:enter` pseudo-class. If a string is passed, its value will be
used for the outline declaration.
```js
postcssPseudoClassEnter({ outline: true }); // adds outline: 0;
```
Enable [:enter] within your Gruntfile:
```js
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
postcss: {
options: {
processors: [
require('postcss-pseudo-class-enter')({ /* options */ })
]
},
dist: {
src: 'css/*.css'
}
}
});
postcssPseudoClassEnter({ outline: 'none' }); // adds outline: none;
```

@@ -137,8 +100,6 @@

#### Use @custom-selector (supported nowhere yet)
#### Use :focus and :hover (supported everywhere)
```css
@custom-selector :--enter :focus, :hover;
:--enter { /* ... */ }
:focus, :hover { /* ... */ }
```

@@ -152,6 +113,8 @@

#### Use :focus and :hover (supported everywhere)
#### Use @custom-selector (supported nowhere yet)
```css
:focus, :hover { /* ... */ }
@custom-selector :--enter :focus, :hover;
:--enter { /* ... */ }
```

@@ -167,21 +130,15 @@

[npm-url]: https://www.npmjs.com/package/postcss-pseudo-class-enter
[npm-img]: https://img.shields.io/npm/v/postcss-pseudo-class-enter.svg
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-pseudo-class-enter.svg
[cli-url]: https://travis-ci.org/jonathantneal/postcss-pseudo-class-enter
[cli-img]: https://img.shields.io/travis/jonathantneal/postcss-pseudo-class-enter.svg
[lic-url]: LICENSE.md
[lic-image]: https://img.shields.io/npm/l/postcss-pseudo-class-enter.svg
[log-url]: CHANGELOG.md
[log-image]: https://img.shields.io/badge/changelog-md-blue.svg
[git-img]: https://img.shields.io/badge/support-chat-blue.svg
[git-url]: https://gitter.im/postcss/postcss
[git-image]: https://img.shields.io/badge/chat-gitter-blue.svg
[npm-img]: https://img.shields.io/npm/v/postcss-pseudo-class-enter.svg
[npm-url]: https://www.npmjs.com/package/postcss-pseudo-class-enter
[:enter]: https://github.com/jonathantneal/postcss-pseudo-class-enter
[`:enter`]: http://discourse.specifiction.org/t/a-common-pseudo-class-for-hover-and-focus/877
[`:focus`]: http://dev.w3.org/csswg/selectors/#focus-pseudo
[`:hover`]: http://dev.w3.org/csswg/selectors/#visited-pseudo
[proposal]: http://discourse.specifiction.org/t/a-common-pseudo-class-for-hover-and-focus/877
[Gulp PostCSS]: https://github.com/postcss/gulp-postcss
[Grunt PostCSS]: https://github.com/nDmitry/grunt-postcss
[`:enter`]: https://discourse.specifiction.org/t/a-common-pseudo-class-for-hover-and-focus/877
[`:focus`]: https://dev.w3.org/csswg/selectors/#focus-pseudo
[`:hover`]: https://dev.w3.org/csswg/selectors/#visited-pseudo
[PostCSS]: https://github.com/postcss/postcss
[Sass]: http://sass-lang.com/
[PostCSS Enter Pseudo Class]: https://github.com/jonathantneal/postcss-pseudo-class-enter
[proposal]: https://discourse.specifiction.org/t/a-common-pseudo-class-for-hover-and-focus/877
[Sass]: https://sass-lang.com/
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