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

ampersand-dom-bindings

Package Overview
Dependencies
Maintainers
3
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-dom-bindings - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

8

ampersand-dom-bindings.js

@@ -79,2 +79,10 @@ var Store = require('key-tree-store');

};
} else if (type === 'value') {
return function (el, value) {
getMatches(el, selector).forEach(function (match) {
if (!value && value !== 0) value = '';
match.value = value;
});
previousValue = value;
};
} else if (type === 'booleanClass') {

@@ -81,0 +89,0 @@ // if there's a `no` case this is actually a switch

2

package.json
{
"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.2.0",
"version": "2.3.0",
"author": "'Henrik Joreteg' <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -56,2 +56,13 @@ # ampersand-dom-bindings

### value
sets the value of the element to match value of the property. works well for `input`, `select`, and `textarea` elements. treats `undefined`, `null`, and `NaN` as `''` (empty string).
```js
'model.key': {
type: 'value',
selector: '#something', // or role
}
```
### booleanClass

@@ -58,0 +69,0 @@

@@ -79,2 +79,35 @@ var test = require('tape');

test('value bindings', function (t) {
var input = getEl('<input class="thing" type="text">');
var select = getEl('<select class="thing"><option value=""></option><option value="hello"></option><option value="string"></option></select>');
var textarea = getEl('<textarea class="thing"></textarea>');
[input, select, textarea].forEach(function (el) {
var bindings = domBindings({
'model': {
type: 'value',
selector: '.thing'
}
});
t.equal(el.firstChild.value, '');
bindings.run('model', null, el, 'hello');
t.equal(el.firstChild.value, 'hello');
bindings.run('model', null, el, 'string');
t.equal(el.firstChild.value, 'string');
bindings.run('model', null, el, void 0);
t.equal(el.firstChild.value, '');
bindings.run('model', null, el, null);
t.equal(el.firstChild.value, '');
bindings.run('model', null, el, NaN);
t.equal(el.firstChild.value, '');
});
t.end();
});
/*

@@ -81,0 +114,0 @@ ### booleanClass

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