ampersand-dom-bindings
Advanced tools
Comparing version 3.6.0 to 3.7.0
@@ -6,31 +6,2 @@ /*$AMPERSAND_VERSION*/ | ||
var partial = require('lodash.partial'); | ||
// returns a key-tree-store of functions | ||
// that can be applied to any element/model. | ||
// all resulting functions should be called | ||
// like func(el, value, lastKeyName) | ||
module.exports = function (bindings, context) { | ||
var store = new Store(); | ||
var key, current; | ||
for (key in bindings) { | ||
current = bindings[key]; | ||
if (typeof current === 'string') { | ||
store.add(key, getBindingFunc({ | ||
type: 'text', | ||
selector: current | ||
})); | ||
} else if (current.forEach) { | ||
current.forEach(function (binding) { | ||
store.add(key, getBindingFunc(binding, context)); | ||
}); | ||
} else { | ||
store.add(key, getBindingFunc(current, context)); | ||
} | ||
} | ||
return store; | ||
}; | ||
var slice = Array.prototype.slice; | ||
@@ -78,14 +49,16 @@ | ||
function getSelector(binding) { | ||
if (typeof binding.selector === 'string') { | ||
return binding.selector; | ||
} else if (binding.hook) { | ||
return '[data-hook~="' + binding.hook + '"]'; | ||
} else { | ||
return ''; | ||
} | ||
} | ||
function getBindingFunc(binding, context) { | ||
var type = binding.type || 'text'; | ||
var isCustomBinding = typeof type === 'function'; | ||
var selector = (function () { | ||
if (typeof binding.selector === 'string') { | ||
return binding.selector; | ||
} else if (binding.hook) { | ||
return '[data-hook~="' + binding.hook + '"]'; | ||
} else { | ||
return ''; | ||
} | ||
})(); | ||
var selector = getSelector(binding); | ||
var yes = binding.yes; | ||
@@ -260,1 +233,29 @@ var no = binding.no; | ||
} | ||
// returns a key-tree-store of functions | ||
// that can be applied to any element/model. | ||
// all resulting functions should be called | ||
// like func(el, value, lastKeyName) | ||
module.exports = function (bindings, context) { | ||
var store = new Store(); | ||
var key, current; | ||
for (key in bindings) { | ||
current = bindings[key]; | ||
if (typeof current === 'string') { | ||
store.add(key, getBindingFunc({ | ||
type: 'text', | ||
selector: current | ||
})); | ||
} else if (current.forEach) { | ||
current.forEach(function (binding) { | ||
store.add(key, getBindingFunc(binding, context)); | ||
}); | ||
} else { | ||
store.add(key, getBindingFunc(current, context)); | ||
} | ||
} | ||
return store; | ||
}; |
{ | ||
"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.6.0", | ||
"version": "3.7.0", | ||
"author": "'Henrik Joreteg' <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "browserify": { |
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
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21334
243