Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

ampersand-dom-bindings

Package Overview
Dependencies
13
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.3.2 to 3.3.3

10

ampersand-dom-bindings.js

@@ -12,3 +12,3 @@ /*$AMPERSAND_VERSION*/

// like func(el, value, lastKeyName)
module.exports = function (bindings) {
module.exports = function (bindings, context) {
var store = new Store();

@@ -26,6 +26,6 @@ var key, current;

current.forEach(function (binding) {
store.add(key, getBindingFunc(binding));
store.add(key, getBindingFunc(binding, context));
});
} else {
store.add(key, getBindingFunc(current));
store.add(key, getBindingFunc(current, context));
}

@@ -51,3 +51,3 @@ }

function getBindingFunc(binding) {
function getBindingFunc(binding, context) {
var type = binding.type || 'text';

@@ -74,3 +74,3 @@ var isCustomBinding = typeof type === 'function';

getMatches(el, selector).forEach(function (match) {
type(match, value, previousValue);
type.call(context, match, value, previousValue);
});

@@ -77,0 +77,0 @@ previousValue = value;

{
"name": "ampersand-dom-bindings",
"description": "Takes binding declarations and returns key-tree-store of functions that can be used to apply those bindings.",
"version": "3.3.2",
"version": "3.3.3",
"author": "'Henrik Joreteg' <henrik@andyet.net>",

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

@@ -162,3 +162,4 @@ # ampersand-dom-bindings

`type` can also be a function. It will be run for each matching `el` with the
`value` and `previousValue` of the property.
`value` and `previousValue` of the property. The function is bound to the view
declaring the bindings, so `this` refers to the view.

@@ -165,0 +166,0 @@ ```js

@@ -476,2 +476,20 @@ var test = require('tape');

test('custom binding with context', function (t) {
var el = getEl('<span class="thing"></span>');
var custom = function (bindingEl) {
dom.text(bindingEl, 'this.value was ' + this.value);
};
var bindings = domBindings({
'model': {
type: custom,
selector: '.thing'
}
}, { value: 'goodbye' });
bindings.run('model', null, el, 'hello');
t.equal(el.firstChild.textContent, 'this.value was goodbye');
t.end();
});
//Bad type is an error

@@ -478,0 +496,0 @@ test('Errors on a bad type', function (t) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc