Файл: library/wysihtml5/src/dom/delegate.js
Строк: 32
<?php
/**
* Event Delegation
*
* @example
* wysihtml5.dom.delegate(document.body, "a", "click", function() {
* // foo
* });
*/
(function(wysihtml5) {
wysihtml5.dom.delegate = function(container, selector, eventName, handler) {
return wysihtml5.dom.observe(container, eventName, function(event) {
var target = event.target,
match = wysihtml5.lang.array(container.querySelectorAll(selector));
while (target && target !== container) {
if (match.contains(target)) {
handler.call(target, event);
break;
}
target = target.parentNode;
}
});
};
})(wysihtml5);
?>