🚀 DAY 4 OF LAUNCH WEEK: Introducing GitHub Actions Scanning Support.Learn more →
Socket
Book a DemoInstallSign in
Socket

z-modifier

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

z-modifier

Handles BEM-inspired modifier classes on a DOM element.

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

z-modifier

Build Status npm version

This module was written to handle modifier classes inspired by the BEM methodology.

Since it's a CommonJS module, it must be used alongside with Browserify, or something similar, like WebPacker.

Example, explanation

<div id="module"></div>
var Modifier = require('z-modifier');

var mod = new Modifier(
    $('#module'),
    'module'. // The base class the modifier string will be attached to
    '--', // Modifier separator, optional
    '_' // Value separator, optional
);

mod.on('modifier');
// -> Adds the "module--modifier" class
mod.get('modifier');
// -> true

mod.set('modifier', 'value');
// -> Replaces the "module--modifier" class with "module--modifier_value".
mod.get('modifier');
// -> 'value'

mod.off('modifier');
// Removes the "module--modifier_value" class.
mod.get('modifier');
// -> false

mod.toggle('modifier');
// -> Adds the "module--modifier" class.
mod.toggle('modifier');
// -> Removes the "module--modifier" class.

License

MIT

Keywords

modifier

FAQs

Package last updated on 23 Jun 2015

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