Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function domEvent(sig, selector, exp, spec) {
var evt = selector.event,
name = selector.name,
mark = selector.mark,
target = selector.target,
filters = dl.array(selector.filters),
registry = target ? external : internal,
type = target ? target+':'+evt : evt,
node = registry.nodes[type] || (registry.nodes[type] = new df.Node(model)),
handlers = registry.handlers[type] || (registry.handlers[type] = []);
if (name) {
filters.push('!!event.vg.name["' + name + '"]'); // Mimic event bubbling
} else if (mark) {
filters.push('event.vg.item.mark && event.vg.item.mark.marktype==='+dl.str(mark));
}
handlers.push({
signal: sig,
exp: exp,
spec: spec,
filters: filters.map(function(f) { return model.expr(f); })
});
node.addListener(sig);
prototype.model = function(model) {
if (!arguments.length) return this._model;
if (this._model !== model) {
this._model = model;
this._streamer = new df.Node(model);
this._streamer._rank = -1; // HACK: To reduce re-ranking churn.
this._changeset = df.ChangeSet.create();
if (this._handler) this._handler.model(model);
}
return this;
};
global.viewFactory = function(model) {
model.scene(new Node(model)).fire();
return model;
};
function build() {
var v = this;
v._renderNode = new df.Node(v._model)
.router(true);
v._renderNode.evaluate = function(input) {
log.debug(input, ['rendering']);
var s = v._model.scene(),
h = v._handler;
if (h && h.scene) h.scene(s);
if (input.trans) {
input.trans.start(function(items) { v._renderer.render(s, items); });
} else if (v._repaint) {
v._renderer.render(s);
} else if (input.dirty.length) {
v._renderer.render(s, input.dirty);