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

chi-classes

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

chi-classes - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

10

index.js

@@ -37,2 +37,12 @@ var union = require('mout/array/union'),

ClassList.prototype.set = function(classes, value) {
if (value) {
this.add(classes);
} else {
this.remove(classes);
}
return this;
};
ClassList.prototype.has = function(classes) {

@@ -39,0 +49,0 @@ classes = split(classes);

6

package.json
{
"name": "chi-classes",
"version": "0.0.3",
"version": "0.0.4",
"description": "Easily manage CSS classes on DOM nodes",

@@ -27,9 +27,9 @@ "main": "index.js",

"devDependencies": {
"tape": "~1.0.4",
"tape": "~1.1.1",
"hut-build": "~0.1.4"
},
"dependencies": {
"flatten-list": "0.0.1",
"flatten-list": "~0.0.2",
"mout": "~0.7.1"
}
}

@@ -32,2 +32,5 @@ # chi-classes

// Add/remove classes depending on a boolean value
classes(div).set('selected', isSelected);
// Chaining

@@ -80,2 +83,9 @@ classes(div).add('active').remove('foo');

### `#set(classes, value)`
If `value` is truthy, adds the specified classes to all nodes. Otherwise it
removes the classes from all nodes.
Returns `this`, which can be used to chain methods.
### `#has(classes)`

@@ -82,0 +92,0 @@

@@ -108,2 +108,25 @@ var test = require('tape'),

test('set', function(t) {
t.test('add classes when value is true', function(t) {
var node = document.createElement('div');
node.className = 'foo';
classes(node).set('foo bar', true);
t.equal(node.className, 'foo bar');
t.end();
});
t.test('remove classes when value is false', function(t) {
var node = document.createElement('div');
node.className = 'bar baz';
classes(node).set('foo bar', false);
t.equal(node.className, 'baz');
t.end();
});
t.end();
});
test('has', function(t) {

@@ -110,0 +133,0 @@

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