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

postcss-class-patterns

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-class-patterns

PostCSS plugin to match class patterns (prefix, suffix, contains) in a SAFE way.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

PostCSS Class Patterns Build Status

PostCSS plugin to match class patterns (prefix, suffix, contains) in a SAFE way. This is achieved by combining different attribute selectors with all possible class delimiters (spaces, tabs, line feed, form feed, carriage return). This plugin is inspired by this post and follows the HTML5 Spec

Supports the pseudo-classes :class-starts-with(), :class-ends-with() and :class-contains().

/* input */
:class-starts-with(button-) {

}
/* output */
[class^="button-"],
[class*=" button-"],
[class*="\abutton-"],
[class*="\cbutton-"],
[class*="\dbutton-"],
[class*="\9button-"] {
    color:blue;
}',

which matches

<div class="button-blue">matched</div>
<div class="some other classes button-blue">matched</div>
<div class="some-button-blue">not matched</div>
/* input */
a:class-ends-with(-active) {
    color: red;
}
/* output */
a[class$="-active"],
a[class*="-active "],
a[class*="-active\a"],
a[class*="-active\c"],
a[class*="-active\d"],
a[class*="-active\9"] {
    color:red;
}',
/* input */
a:class-contains(abc) {
    color: green;
}
/* output */
a[class*="abc"] {
    color: green;
}

Usage

postcss([ require('postcss-class-patterns') ])

See PostCSS docs for examples for your environment.

Keywords

FAQs

Package last updated on 29 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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