chi-classes
Advanced tools
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); |
{ | ||
"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 @@ |
23
test.js
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10933
198
93
+ Addedflatten-list@0.0.2(transitive)
- Removedflatten-list@0.0.1(transitive)
Updatedflatten-list@~0.0.2