can-view-target
target(nodes)
Create a document fragment that can be cloned but have callbacks be called quickly on elements within the cloned fragment.
var viewTarget = require("can-view-target");
var target = viewTarget([
{
tag: "h1",
callbacks: [function(data){
this.className = data.className
}],
children: [
"Hello ",
function(data){
this.nodeValue = data.message
}
]
},
]);
// target.clone -> <h1>|Hello||</h1>
// target.paths -> path: [0], callbacks: [], children: {paths: [1], callbacks:[function(){}]}
var frag = target.hydrate({className: "title", message: "World"});
frag //-> <h1 class='title'>Hello World</h1>
Parameters
- nodes
{Array}
: