
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
can-view-callbacks
Advanced tools
Registered callbacks for behaviors
{Object}
Registered callbacks for behaviors
Object
callbacks.tag(tagName, tagHandler(el, tagData))
Registers the tagHandler
callback when tagName
is found
in a template.
var $ = require("jquery");
require("jquery-datepicker");
var callbacks = require("can-view-callbacks");
callbacks.tag("date-picker", function(el){
$(el).datePicker();
});
tagName {String}
:
A lower-case, hypenated or colon-seperated html
tag. Example: "my-widget"
or "my:widget"
. It is considered a best-practice to
have a hypen or colon in all custom-tag names.
tagHandler {function(el, tagData)}
:
Adds custom behavior to el
. If tagHandler
returns data, it is used to
render tagData.subtemplate
and the result is inserted as the childNodes of el
.
{Object}
The data passed to tag.
Object
subtemplate {can.view.renderer}
:
If the special tag has content,
the content can be rendered with subtemplate. For example:
callbacks.tag("foo-bar", function(el, tagData){
var frag = tagData.subtemplate(tagData.scope, tagData.options);
$(el).html(frag);
})
scope {can-view-scope}
:
The scope of the element.
options {can.view.Options}
:
The mustache helpers and other non-data values passed to the template.
callbacks.attr(attributeName, attrHandler(el, attrData))
var callbacks = require("can-view-callbacks");
callbacks.attr("show-when", function(el, attrData){
var prop = el.getAttribute("show-when");
var compute = attrData.compute(prop);
var showOrHide = function(){
var val = compute();
if(val) {
el.style.display = 'block';
} else {
el.style.display = 'hidden';
}
};
compute.bind("change", showOrHide);
showOrHide();
el.addEventListener("removed", function onremove(){
compute.unbind("change", showOrHide);
el.removeEventListener("removed", onremove);
});
});
attributeName {String|RegExp}
:
A lower-case attribute name or regular expression
that matches attribute names. Examples: "my-fill"
or /my-\w/
.
attrHandler {function(el, attrData)}
:
A function that adds custom behavior to el
.
{Object}
The data provided to [can.view-callbacks.attr].
Object
scope {can-view-scope}
:
The scope of the element.
options {can.view.Options}
:
The mustache helpers and other non-data values passed to the template.
attributeName {String}
:
The attribute name that was matched.
To make a build of the distributables into dist/
in the cloned repository run
npm install
node build
Tests can run in the browser by opening a webserver and visiting the test.html
page.
Automated tests that run the tests from the command line in Firefox can be run with
npm test
FAQs
Registered callbacks for behaviors
The npm package can-view-callbacks receives a total of 2,954 weekly downloads. As such, can-view-callbacks popularity was classified as popular.
We found that can-view-callbacks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.