Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Y.Node.prototype.on = function (type, fn) {
if (type === "attributes") {
// YUI changes where the extra data comes from
var el = can.$(this);
can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1);
var handle = oldOn.apply(this, arguments),
oldDetach = handle.detach;
handle.detach = function () {
var cur = can.data(el, "canHasAttributesBindings") || 0;
if (cur <= 0) {
can.cleanData(el, "canHasAttributesBindings");
} else {
can.data(el, "canHasAttributesBindings", cur - 1);
}
return oldDetach.apply(this, arguments);
};
return handle;
} else {
return oldOn.apply(this, arguments);
}
onAdd: function () {
var el = can.$(this);
can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1);
},
onRemove: function () {
nodelist.each(function (node) {
node = can.$(node);
var events = can.data(node, 'events'),
eventName = ev + ':' + selector;
if (!events) {
can.data(node, 'events', events = {});
}
if (!events[eventName]) {
events[eventName] = {};
}
if (cb.__bindingsIds === undefined) {
cb.__bindingsIds = yuiEventId++;
}
events[eventName][cb.__bindingsIds] = selector ? node.item(0)
.delegate(ev, cb, selector) : node.item(0)
.on(ev, cb);
});
} else {
nodelist.each(function (node) {
node = can.$(node);
var events = can.data(node, 'events');
if (events) {
var eventName = ev + ':' + selector,
handlers = events[eventName],
handler = handlers[cb.__bindingsIds];
handler.detach();
delete handlers[cb.__bindingsIds];
if (can.isEmptyObject(handlers)) {
delete events[ev];
}
if (can.isEmptyObject(events)) {
}
}
});
} else {
this.each(function () {
var el = can.$(this),
cur = can.data(el, "canHasAttributesBindings") || 0;
if (cur <= 0) {
can.data(el, "canHasAttributesBindings", 0);
} else {
can.data(el, "canHasAttributesBindings", cur - 1);
}
});
}
this.each(function () {
var el = can.$(this);
can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1);
});
}
onRemove: function () {
var el = can.$(this),
cur = can.data(el, "canHasAttributesBindings") || 0;
if (cur <= 0) {
can.cleanData(el, "canHasAttributesBindings");
} else {
can.data(el, "canHasAttributesBindings", cur - 1);
}
}
};
this.each(function () {
var el = can.$(this),
cur = can.data(el, "canHasAttributesBindings") || 0;
if (cur <= 0) {
can.data(el, "canHasAttributesBindings", 0);
} else {
can.data(el, "canHasAttributesBindings", cur - 1);
}
});
}
nodelist.each(function (node) {
node = can.$(node);
var events = can.data(node, 'events'),
eventName = ev + ':' + selector;
if (!events) {
can.data(node, 'events', events = {});
}
if (!events[eventName]) {
events[eventName] = {};
}
if (cb.__bindingsIds === undefined) {
cb.__bindingsIds = yuiEventId++;
}
events[eventName][cb.__bindingsIds] = selector ? node.item(0)
.delegate(ev, cb, selector) : node.item(0)
.on(ev, cb);
});
} else {
handle.detach = function () {
var cur = can.data(el, "canHasAttributesBindings") || 0;
if (cur <= 0) {
can.cleanData(el, "canHasAttributesBindings");
} else {
can.data(el, "canHasAttributesBindings", cur - 1);
}
return oldDetach.apply(this, arguments);
};
return handle;