How to use the can/util/can.data function in can

To help you get started, we’ve selected a few can examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github canjs / canjs / util / yui / yui.js View on Github external
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);
		}
github canjs / canjs / util / mootools / mootools.js View on Github external
onAdd: function () {
		var el = can.$(this);
		can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1);
	},
	onRemove: function () {
github canjs / canjs / util / yui / yui.js View on Github external
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 {
github canjs / canjs / util / yui / yui.js View on Github external
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 {
github canjs / canjs / util / zepto / zepto.js View on Github external
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);
			}
		});
	}
github canjs / canjs / util / zepto / zepto.js View on Github external
this.each(function () {
			var el = can.$(this);
			can.data(el, "canHasAttributesBindings", (can.data(el, "canHasAttributesBindings") || 0) + 1);
		});
	}
github canjs / canjs / util / mootools / mootools.js View on Github external
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);
		}
	}
};
github canjs / canjs / util / zepto / zepto.js View on Github external
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);
			}
		});
	}
github canjs / canjs / util / yui / yui.js View on Github external
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 {
github canjs / canjs / util / yui / yui.js View on Github external
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;