ampersand-dom-bindings
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -93,5 +93,8 @@ var Store = require('key-tree-store'); | ||
return function (el, value, keyName) { | ||
var name = binding.name || binding.yes || keyName; | ||
var yes = binding.name || binding.yes || keyName; | ||
var no = binding.no; | ||
getMatches(el, selector).forEach(function (match) { | ||
dom.switchClass(match, binding.no, name); | ||
var prevClass = value ? no : yes; | ||
var newClass = value ? yes : no; | ||
dom.switchClass(match, prevClass, newClass); | ||
}); | ||
@@ -98,0 +101,0 @@ }; |
{ | ||
"name": "ampersand-dom-bindings", | ||
"description": "Takes binding declarations and returns key-tree-store of functions that can be used to apply those bindings.", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"author": "'Henrik Joreteg' <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -153,2 +153,27 @@ var test = require('tape'); | ||
test('booleanClass yes/no bindings', function (t) { | ||
var el = getEl('<input type="checkbox" class="thing" role="some-role">'); | ||
var bindings = domBindings({ | ||
'model': { | ||
type: 'booleanClass', | ||
selector: '.thing', | ||
yes: 'awesome', | ||
no: 'not-awesome' | ||
} | ||
}); | ||
t.notOk(dom.hasClass(el.firstChild, 'awesome'), 'should not start with yes class'); | ||
t.notOk(dom.hasClass(el.firstChild, 'not-awesome'), 'should not start with no class'); | ||
bindings.run('', null, el, true); | ||
t.ok(dom.hasClass(el.firstChild, 'awesome'), 'should have yes class'); | ||
t.notOk(dom.hasClass(el.firstChild, 'not-awesome'), 'should not have no class'); | ||
bindings.run('', null, el, false); | ||
t.notOk(dom.hasClass(el.firstChild, 'awesome'), 'should not have yes class'); | ||
t.ok(dom.hasClass(el.firstChild, 'not-awesome'), 'should have no class'); | ||
t.end(); | ||
}); | ||
test('booleanAttribute bindings', function (t) { | ||
@@ -155,0 +180,0 @@ var el = getEl('<input type="checkbox" class="thing" role="some-role">'); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
19274
329
0