Socket
Socket
Sign inDemoInstall

css.escape

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css.escape

A robust polyfill for the `CSS.escape` utility method as defined in CSSOM.


Version published
Maintainers
1
Install size
7.10 kB
Created

Package description

What is css.escape?

The css.escape npm package provides a utility for escaping strings to be used as CSS identifiers. It implements the CSS.escape() method, which allows for the escaping of characters that are not valid CSS identifier characters. This is particularly useful when dynamically generating class names, IDs, or other selectors that may contain special characters not typically allowed in CSS selectors.

What are css.escape's main functionalities?

Escaping strings for CSS identifiers

This feature allows you to escape any string to make it a valid CSS identifier. For example, if you have a class name that includes special characters or starts with a digit, you can use css.escape to ensure it's valid. The code sample demonstrates how to escape the string 'my-class' to be safely used as a CSS class name.

"CSS.escape('my-class');"

Other packages similar to css.escape

Readme

Source

CSS.escape polyfill Build status Code coverage status

A robust polyfill for the CSS.escape utility method as defined in CSSOM.

For a more powerful alternative, consider using cssesc, which automatically takes care of excessive whitespace, and has many options to customize the output.

Installation

In a browser:

<script src="css.escape.js"></script>

Via npm:

npm install css.escape

Then, in Node.js:

require('css.escape');

// On Windows and on Mac systems with default settings, case doesn’t matter,
// which allows you to do this instead:
require('CSS.escape');

Author

twitter/mathias
Mathias Bynens

License

This polyfill is available under the MIT license.

Keywords

FAQs

Last updated on 23 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc