(function(Pitaya, window) { "use strict"; var DOM = Pitaya.DOM = {}; /** * Select an element in the DOM by its CSS selector * * @private * @param selector The CSS selector * @return The selected element or null */ DOM.select = function(selector) { return window.document.querySelector(selector); }; /** * Select all elements in the DOM with a CSS selector * * @private * @param selector The CSS selector * @return An array of the selected elements (if any) */ DOM.selectAll = function(selector) { return window.document.querySelectorAll(selector); }; /** * Find the closest ancestor matching the CSS selector * * @private * @param selector The CSS selector * @return An array of the selected elements (if any) */ DOM.getClosestAncestor = function(el, selector) { var parent = el.parentElement; if(parent) { if(parent.matches(selector)) { return parent; } else { return DOM.getClosestAncestor(parent, selector); } } return false; }; }(window.Pitaya = window.Pitaya || {}, window));