- Presidente Presidente
- Governador Governo
- Senador Senado
- Federal Federal
- Estadual Estadual
'+a.partido.sigla+" • "+a.nomeColigacao+"
\nevergreen
');\n */\n\nconst domtastic = function domtastic(selector, context = document) {\n\n let collection;\n\n if(!selector) {\n\n collection = document.querySelectorAll(null);\n\n } else if(selector instanceof DOMtastic) {\n\n return selector;\n\n } else if(typeof selector !== 'string') {\n\n collection = selector.nodeType || selector === window ? [selector] : selector;\n\n } else if(reFragment.test(selector)) {\n\n collection = createFragment(selector);\n\n } else {\n\n context = typeof context === 'string' ? document.querySelector(context) : context.length ? context[0] : context;\n\n collection = querySelector(selector, context);\n\n }\n\n return wrap(collection);\n\n};\n\nexport const $ = domtastic;\n\n/*\n * Find descendants matching the provided `selector` for each element in the collection.\n *\n * @param {String|Node|NodeList|Array} selector Query selector, `Node`, `NodeList`, array of elements, or HTML fragment string.\n * @return {Object} The wrapped collection\n * @example\n * $('.selector').find('.deep').$('.deepest');\n */\n\nexport const find = function(selector) {\n const nodes = [];\n each(this, node => each(querySelector(selector, node), child => {\n if(nodes.indexOf(child) === -1) {\n nodes.push(child);\n }\n }));\n return $(nodes);\n};\n\n/*\n * Returns `true` if the element would be selected by the specified selector string; otherwise, returns `false`.\n *\n * @param {Node} element Element to test\n * @param {String} selector Selector to match against element\n * @return {Boolean}\n *\n * @example\n * $.matches(element, '.match');\n */\n\nexport const matches = (() => {\n const context = typeof Element !== 'undefined' ? Element.prototype : win;\n const _matches = context.matches || context.matchesSelector || context.mozMatchesSelector || context.msMatchesSelector || context.oMatchesSelector || context.webkitMatchesSelector;\n return (element, selector) => _matches.call(element, selector);\n})();\n\n/*\n * Use the faster `getElementById`, `getElementsByClassName` or `getElementsByTagName` over `querySelectorAll` if possible.\n *\n * @private\n * @param {String} selector Query selector.\n * @param {Node} context The context for the selector to query elements.\n * @return {Object} NodeList, HTMLCollection, or Array of matching elements (depending on method used).\n */\n\nconst querySelector = (selector, context) => {\n\n const isSimpleSelector = reSimpleSelector.test(selector);\n\n if(isSimpleSelector) {\n if(selector[0] === '#') {\n const element = (context.getElementById ? context : document).getElementById(selector.slice(1));\n return element ? [element] : [];\n }\n if(selector[0] === '.') {\n return context.getElementsByClassName(selector.slice(1));\n }\n return context.getElementsByTagName(selector);\n }\n\n return context.querySelectorAll(selector);\n\n};\n\n/*\n * Create DOM fragment from an HTML string\n *\n * @private\n * @param {String} html String representing HTML.\n * @return {NodeList}\n */\n\nconst createFragment = html => {\n\n if(reSingleTag.test(html)) {\n return [document.createElement(RegExp.$1)];\n }\n\n const elements = [];\n const container = document.createElement('div');\n const children = container.childNodes;\n\n container.innerHTML = html;\n\n for(let i = 0, l = children.length; i < l; i++) {\n elements.push(children[i]);\n }\n\n return elements;\n};\n\n/*\n * Calling `$(selector)` returns a wrapped collection of elements.\n *\n * @private\n * @param {NodeList|Array} collection Element(s) to wrap.\n * @return Object) The wrapped collection\n */\n\nconst wrap = collection => {\n\n if(!isPrototypeSet) {\n DOMtastic.prototype = $.fn;\n DOMtastic.prototype.constructor = DOMtastic;\n isPrototypeSet = true;\n }\n\n return new DOMtastic(collection);\n};\n\n/*\n * Constructor for the Object.prototype strategy\n *\n * @constructor\n * @private\n * @param {NodeList|Array} collection Element(s) to wrap.\n */\n\nexport const DOMtastic = function DOMtastic(collection) {\n let i = 0;\n const length = collection.length;\n for(; i < length;) {\n this[i] = collection[i++];\n }\n this.length = length;\n};\n","/**\n * @module Array\n */\n\nimport { each as _each, toArray } from './util';\nimport { $, matches } from './selector/index';\n\nconst ArrayProto = Array.prototype;\n\n/**\n * Checks if the given callback returns a true(-ish) value for each element in the collection.\n *\n * @param {Function} callback Function to execute for each element, invoked with `element` as argument.\n * @param {Object} [thisArg] Value to use as `this` when executing `callback`.\n * @return {Boolean} Whether each element passed the callback check.\n * @example\n * // Test whether every element in the collection has the \"active\" attribute\n * $('.items').every(function(element) {\n * return element.hasAttribute('active')\n * });\n */\n\nexport const every = ArrayProto.every;\n\n/**\n * Filter the collection by selector or function, and return a new collection with the result.\n *\n * @param {String|Function} selector Selector or function to filter the collection.\n * @param {Object} [thisArg] Value to use as `this` when executing `callback`.\n * @return {Object} A new wrapped collection\n * @chainable\n * @example\n * $('.items').filter('.active');\n * @example\n * $('.items').filter(function(element) {\n * return element.hasAttribute('active')\n * });\n */\n\nexport const filter = function(selector, thisArg) {\n const callback = typeof selector === 'function' ? selector : element => matches(element, selector);\n return $(ArrayProto.filter.call(this, callback, thisArg));\n};\n\n/**\n * Execute a function for each element in the collection.\n *\n * @param {Function} callback Function to execute for each element, invoked with `element` as argument.\n * @param {Object} [thisArg] Value to use as `this` when executing `callback`.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.items').forEach(function(element) {\n * element.style.color = 'evergreen';\n * );\n */\n\nexport const forEach = function(callback, thisArg) {\n return _each(this, callback, thisArg);\n};\n\nexport const each = forEach;\n\n/**\n * Returns the index of an element in the collection.\n *\n * @param {Node} element\n * @return {Number} The zero-based index, -1 if not found.\n * @example\n * $('.items').indexOf(element); // 2\n */\n\nexport const indexOf = ArrayProto.indexOf;\n\n/**\n * Create a new collection by executing the callback for each element in the collection.\n *\n * @param {Function} callback Function to execute for each element, invoked with `element` as argument.\n * @param {Object} [thisArg] Value to use as `this` when executing `callback`.\n * @return {Array} Collection with the return value of the executed callback for each element.\n * @example\n * // Create a new array with the attribute value of each element:\n * $('.items').map(function(element) {\n * return element.getAttribute('name')\n */\n\nexport const map = ArrayProto.map;\n\n/**\n * Removes the last element from the collection, and returns that element.\n *\n * @return {Object} The last element from the collection.\n * @example\n * var lastElement = $('.items').pop();\n */\n\nexport const pop = ArrayProto.pop;\n\n/**\n * Adds one or more elements to the end of the collection, and returns the new length of the collection.\n *\n * @param {Object} element Element(s) to add to the collection\n * @return {Number} The new length of the collection\n * @example\n * $('.items').push(element);\n */\n\nexport const push = ArrayProto.push;\n\n/**\n * Apply a function against each element in the collection, and this accumulator function has to reduce it\n * to a single value.\n *\n * @param {Function} callback Function to execute on each value in the array, taking four arguments (see example).\n * @param {Mixed} initialValue Object to use as the first argument to the first call of the callback.\n * @example\n * // Calculate the combined height of elements:\n * $('.items').reduce(function(previousValue, element, index, collection) {\n * return previousValue + element.clientHeight;\n * }, 0);\n */\n\nexport const reduce = ArrayProto.reduce;\n\n/**\n * Apply a function against each element in the collection (from right-to-left), and this accumulator function has\n * to reduce it to a single value.\n *\n * @param {Function} callback Function to execute on each value in the array, taking four arguments (see example).\n * @param {Mixed} initialValue Object to use as the first argument to the first call of the callback.\n * @example\n * // Concatenate the text of elements in reversed order:\n * $('.items').reduceRight(function(previousValue, element, index, collection) {\n * return previousValue + element.textContent;\n * }, '');\n */\n\nexport const reduceRight = ArrayProto.reduceRight;\n\n/**\n * Reverses an array in place. The first array element becomes the last and the last becomes the first.\n *\n * @return {Object} The wrapped collection, reversed\n * @chainable\n * @example\n * $('.items').reverse();\n */\n\nexport const reverse = function() {\n return $(toArray(this).reverse());\n};\n\n/**\n * Removes the first element from the collection, and returns that element.\n *\n * @return {Object} The first element from the collection.\n * @example\n * var firstElement = $('.items').shift();\n */\n\nexport const shift = ArrayProto.shift;\n\n/**\n * Checks if the given callback returns a true(-ish) value for any of the elements in the collection.\n *\n * @param {Function} callback Function to execute for each element, invoked with `element` as argument.\n * @return {Boolean} Whether any element passed the callback check.\n * @example\n * $('.items').some(function(element) {\n * return element.hasAttribute('active')\n * }); // true/false\n */\n\nexport const some = ArrayProto.some;\n\n/**\n * Adds one or more elements to the beginning of the collection, and returns the new length of the collection.\n *\n * @param {Object} element Element(s) to add to the collection\n * @return {Number} The new length of the collection\n * @example\n * $('.items').unshift(element);\n */\n\nexport const unshift = ArrayProto.unshift;\n","/**\n * @module BaseClass\n */\n\nimport { $ as selector, DOMtastic } from './selector/index';\nimport { extend } from './util';\n\nexport default function(api) {\n\n /**\n * Provide subclass for classes or components to extend from.\n * The opposite and successor of plugins (no need to extend `$.fn` anymore, complete control).\n *\n * @return {Class} The class to extend from, including all `$.fn` methods.\n * @example\n * import { BaseClass } from 'domtastic';\n *\n * class MyComponent extends BaseClass {\n * doSomething() {\n * return this.addClass('.foo');\n * }\n * }\n *\n * let component = new MyComponent('body');\n * component.doSomething();\n *\n * @example\n * import $ from 'domtastic';\n *\n * class MyComponent extends $.BaseClass {\n * progress(value) {\n * return this.attr('data-progress', value);\n * }\n * }\n *\n * let component = new MyComponent(document.body);\n * component.progress('ive').append('enhancement
');\n */\n\n class BaseClass {\n constructor() {\n DOMtastic.call(this, selector(...arguments));\n }\n }\n extend(BaseClass.prototype, api);\n return BaseClass;\n}\n","/**\n * @module CSS\n */\n\nimport { each } from './util';\n\nconst isNumeric = value => !isNaN(parseFloat(value)) && isFinite(value);\n\nconst camelize = value => value.replace(/-([\\da-z])/gi, (matches, letter) => letter.toUpperCase());\n\nconst dasherize = value => value.replace(/([a-z\\d])([A-Z])/g, '$1-$2').toLowerCase();\n\n/**\n * Get the value of a style property for the first element, or set one or more style properties for each element in the collection.\n *\n * @param {String|Object} key The name of the style property to get or set. Or an object containing key-value pairs to set as style properties.\n * @param {String} [value] The value of the style property to set.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').css('padding-left'); // get\n * $('.item').css('color', '#f00'); // set\n * $('.item').css({'border-width': '1px', display: 'inline-block'}); // set multiple\n */\n\nexport const css = function(key, value) {\n\n let styleProps, prop, val;\n\n if(typeof key === 'string') {\n key = camelize(key);\n\n if(typeof value === 'undefined') {\n let element = this.nodeType ? this : this[0];\n if(element) {\n val = element.style[key];\n return isNumeric(val) ? parseFloat(val) : val;\n }\n return undefined;\n }\n\n styleProps = {};\n styleProps[key] = value;\n } else {\n styleProps = key;\n for(prop in styleProps) {\n val = styleProps[prop];\n delete styleProps[prop];\n styleProps[camelize(prop)] = val;\n }\n }\n\n each(this, element => {\n for(prop in styleProps) {\n if(styleProps[prop] || styleProps[prop] === 0) {\n element.style[prop] = styleProps[prop];\n } else {\n element.style.removeProperty(dasherize(prop));\n }\n }\n });\n\n return this;\n};\n","/**\n * @module DOM\n */\n\nimport { toArray } from '../util';\nimport { $ } from '../selector/index';\n\nconst forEach = Array.prototype.forEach;\n\n/**\n * Append element(s) to each element in the collection.\n *\n * @param {String|Node|NodeList|Object} element What to append to the element(s).\n * Clones elements as necessary.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').append('more
');\n */\n\nexport const append = function(element) {\n if(this instanceof Node) {\n if(typeof element === 'string') {\n this.insertAdjacentHTML('beforeend', element);\n } else {\n if(element instanceof Node) {\n this.appendChild(element);\n } else {\n const elements = element instanceof NodeList ? toArray(element) : element;\n forEach.call(elements, this.appendChild.bind(this));\n }\n }\n } else {\n _each(this, append, element);\n }\n return this;\n};\n\n/**\n * Place element(s) at the beginning of each element in the collection.\n *\n * @param {String|Node|NodeList|Object} element What to place at the beginning of the element(s).\n * Clones elements as necessary.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').prepend('start');\n */\n\nexport const prepend = function(element) {\n if(this instanceof Node) {\n if(typeof element === 'string') {\n this.insertAdjacentHTML('afterbegin', element);\n } else {\n if(element instanceof Node) {\n this.insertBefore(element, this.firstChild);\n } else {\n let elements = element instanceof NodeList ? toArray(element) : element;\n forEach.call(elements.reverse(), prepend.bind(this));\n }\n }\n } else {\n _each(this, prepend, element);\n }\n return this;\n};\n\n/**\n * Place element(s) before each element in the collection.\n *\n * @param {String|Node|NodeList|Object} element What to place as sibling(s) before to the element(s).\n * Clones elements as necessary.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.items').before('prefix
');\n */\n\nexport const before = function(element) {\n if(this instanceof Node) {\n if(typeof element === 'string') {\n this.insertAdjacentHTML('beforebegin', element);\n } else {\n if(element instanceof Node) {\n this.parentNode.insertBefore(element, this);\n } else {\n const elements = element instanceof NodeList ? toArray(element) : element;\n forEach.call(elements, before.bind(this));\n }\n }\n } else {\n _each(this, before, element);\n }\n return this;\n};\n\n/**\n * Place element(s) after each element in the collection.\n *\n * @param {String|Node|NodeList|Object} element What to place as sibling(s) after to the element(s). Clones elements as necessary.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.items').after('suffix');\n */\n\nexport const after = function(element) {\n if(this instanceof Node) {\n if(typeof element === 'string') {\n this.insertAdjacentHTML('afterend', element);\n } else {\n if(element instanceof Node) {\n this.parentNode.insertBefore(element, this.nextSibling);\n } else {\n const elements = element instanceof NodeList ? toArray(element) : element;\n forEach.call(elements.reverse(), after.bind(this));\n }\n }\n } else {\n _each(this, after, element);\n }\n return this;\n};\n\n/**\n * Clone a wrapped object.\n *\n * @return {Object} Wrapped collection of cloned nodes.\n * @example\n * $(element).clone();\n */\n\nexport const clone = function() {\n return $(_clone(this));\n};\n\n/**\n * Clone an object\n *\n * @param {String|Node|NodeList|Array} element The element(s) to clone.\n * @return {String|Node|NodeList|Array} The cloned element(s)\n * @private\n */\n\nexport const _clone = element => {\n if(typeof element === 'string') {\n return element;\n } else if(element instanceof Node) {\n return element.cloneNode(true);\n } else if('length' in element) {\n return [].map.call(element, el => el.cloneNode(true));\n }\n return element;\n};\n\n/**\n * Specialized iteration, applying `fn` in reversed manner to a clone of each element, but the provided one.\n *\n * @param {NodeList|Array} collection\n * @param {Function} fn\n * @param {Node} element\n * @private\n */\n\nexport const _each = (collection, fn, element) => {\n let l = collection.length;\n while(l--) {\n const elm = l === 0 ? element : _clone(element);\n fn.call(collection[l], elm);\n }\n};\n","/**\n * @module Attr\n */\n\nimport { each } from '../util';\n\n/**\n * Get the value of an attribute for the first element, or set one or more attributes for each element in the collection.\n *\n * @param {String|Object} key The name of the attribute to get or set. Or an object containing key-value pairs to set as attributes.\n * @param {String} [value] The value of the attribute to set.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').attr('attrName'); // get\n * $('.item').attr('attrName', 'attrValue'); // set\n * $('.item').attr({attr1: 'value1', 'attr-2': 'value2'}); // set multiple\n */\n\nexport const attr = function(key, value) {\n\n if(typeof key === 'string' && typeof value === 'undefined') {\n const element = this.nodeType ? this : this[0];\n return element ? element.getAttribute(key) : undefined;\n }\n\n return each(this, element => {\n if(typeof key === 'object') {\n for(let attr in key) {\n element.setAttribute(attr, key[attr]);\n }\n } else {\n element.setAttribute(key, value);\n }\n });\n};\n\n/**\n * Remove attribute from each element in the collection.\n *\n * @param {String} key Attribute name\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.items').removeAttr('attrName');\n */\n\nexport const removeAttr = function(key) {\n return each(this, element => element.removeAttribute(key));\n};\n","/**\n * @module Class\n */\n\nimport { each } from '../util';\n\n/**\n * Add a class to the element(s)\n *\n * @param {String} value Space-separated class name(s) to add to the element(s).\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').addClass('bar');\n * $('.item').addClass('bar foo');\n */\n\nexport const addClass = function(value) {\n if(value && value.length) {\n each(value.split(' '), _each.bind(this, 'add'));\n }\n return this;\n};\n\n/**\n * Remove a class from the element(s)\n *\n * @param {String} value Space-separated class name(s) to remove from the element(s).\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.items').removeClass('bar');\n * $('.items').removeClass('bar foo');\n */\n\nexport const removeClass = function(value) {\n if(value && value.length) {\n each(value.split(' '), _each.bind(this, 'remove'));\n }\n return this;\n};\n\n/**\n * Toggle a class at the element(s)\n *\n * @param {String} value Space-separated class name(s) to toggle at the element(s).\n * @param {Boolean} [state] A Boolean value to determine whether the class should be added or removed.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').toggleClass('bar');\n * $('.item').toggleClass('bar foo');\n * $('.item').toggleClass('bar', true);\n */\n\nexport const toggleClass = function(value, state) {\n if(value && value.length) {\n const action = typeof state === 'boolean' ? state ? 'add' : 'remove' : 'toggle';\n each(value.split(' '), _each.bind(this, action));\n }\n return this;\n};\n\n/**\n * Check if the element(s) have a class.\n *\n * @param {String} value Check if the DOM element contains the class name. When applied to multiple elements,\n * returns `true` if _any_ of them contains the class name.\n * @return {Boolean} Whether the element's class attribute contains the class name.\n * @example\n * $('.item').hasClass('bar');\n */\n\nexport const hasClass = function(value) {\n return (this.nodeType ? [this] : this).some(element => element.classList.contains(value));\n};\n\n/**\n * Specialized iteration, applying `fn` of the classList API to each element.\n *\n * @param {String} fnName\n * @param {String} className\n * @private\n */\n\nconst _each = function(fnName, className) {\n return each(this, element => element.classList[fnName](className));\n};\n","/**\n * @module contains\n */\n\n/**\n * Test whether an element contains another element in the DOM.\n *\n * @param {Element} container The element that may contain the other element.\n * @param {Element} element The element that may be a descendant of the other element.\n * @return {Boolean} Whether the `container` element contains the `element`.\n * @example\n * $.contains(parentElement, childElement); // true/false\n */\n\nexport const contains = (container, element) => {\n if(!container || !element || container === element) {\n return false;\n } else if(container.contains) {\n return container.contains(element);\n } else if(container.compareDocumentPosition) {\n return !(container.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_DISCONNECTED);\n }\n return false;\n};\n","/**\n * @module Data\n */\n\nimport { each } from '../util';\n\nconst isSupportsDataSet = typeof document !== 'undefined' && 'dataset' in document.documentElement;\nconst DATAKEYPROP = isSupportsDataSet ? 'dataset' : '__DOMTASTIC_DATA__';\n\nconst camelize = str => str.replace(/-+(.)?/g, (match, char) => char ? char.toUpperCase() : '');\n\n/**\n * Get data from first element, or set data for each element in the collection.\n *\n * @param {String} key The key for the data to get or set.\n * @param {String} [value] The data to set.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').data('attrName'); // get\n * $('.item').data('attrName', {any: 'data'}); // set\n */\n\nexport const data = function(key, value) {\n\n if(typeof key === 'string' && typeof value === 'undefined') {\n const element = this.nodeType ? this : this[0];\n return element && DATAKEYPROP in element ? element[DATAKEYPROP][camelize(key)] : undefined;\n }\n\n return each(this, element => {\n if(!isSupportsDataSet) {\n element[DATAKEYPROP] = element[DATAKEYPROP] || {};\n }\n\n element[DATAKEYPROP][camelize(key)] = value;\n });\n};\n\n/**\n * Get property from first element, or set property on each element in the collection.\n *\n * @param {String} key The name of the property to get or set.\n * @param {String} [value] The value of the property to set.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').prop('attrName'); // get\n * $('.item').prop('attrName', 'attrValue'); // set\n */\n\nexport const prop = function(key, value) {\n\n if(typeof key === 'string' && typeof value === 'undefined') {\n const element = this.nodeType ? this : this[0];\n return element && element ? element[key] : undefined;\n }\n\n return each(this, element => element[key] = value);\n};\n","/**\n * @module DOM (extra)\n */\n\nimport { each } from '../util';\nimport { append, before } from './index';\nimport { $ } from '../selector/index';\n\n/**\n * Append each element in the collection to the specified element(s).\n *\n * @param {Node|NodeList|Object} element What to append the element(s) to. Clones elements as necessary.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').appendTo(container);\n */\n\nexport const appendTo = function(element) {\n const context = typeof element === 'string' ? $(element) : element;\n append.call(context, this);\n return this;\n};\n\n/*\n * Empty each element in the collection.\n *\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').empty();\n */\n\nexport const empty = function() {\n return each(this, element => element.innerHTML = '');\n};\n\n/**\n * Remove the collection from the DOM.\n *\n * @return {Array} Array containing the removed elements\n * @example\n * $('.item').remove();\n */\n\nexport const remove = function() {\n return each(this, element => {\n if(element.parentNode) {\n element.parentNode.removeChild(element);\n }\n });\n};\n\n/**\n * Replace each element in the collection with the provided new content, and return the array of elements that were replaced.\n *\n * @return {Array} Array containing the replaced elements\n */\n\nexport const replaceWith = function() {\n return before.apply(this, arguments).remove();\n};\n\n/**\n * Get the `textContent` from the first, or set the `textContent` of each element in the collection.\n *\n * @param {String} [value]\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').text('New content');\n */\n\nexport const text = function(value) {\n\n if(value === undefined) {\n return this[0].textContent;\n }\n\n return each(this, element => element.textContent = '' + value);\n};\n\n/**\n * Get the `value` from the first, or set the `value` of each element in the collection.\n *\n * @param {String} [value]\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('input.firstName').val('New value');\n */\n\nexport const val = function(value) {\n\n if(value === undefined) {\n return this.length > 0 ? this[0].value : undefined;\n }\n\n return each(this, element => element.value = value);\n};\n","/**\n * @module HTML\n */\n\nimport { each } from '../util';\n\n/*\n * Get the HTML contents of the first element, or set the HTML contents for each element in the collection.\n *\n * @param {String} [fragment] HTML fragment to set for the element. If this argument is omitted, the HTML contents are returned.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').html();\n * $('.item').html('more');\n */\n\nexport const html = function(fragment) {\n\n if(fragment === undefined) {\n const element = this.nodeType ? this : this[0];\n return element ? element.innerHTML : undefined;\n }\n\n return each(this, element => element.innerHTML = fragment);\n};\n","/**\n * @module closest\n */\n\nimport { $, matches } from './index';\nimport { each, uniq } from '../util';\n\n/**\n * Return the closest element matching the selector (starting by itself) for each element in the collection.\n *\n * @param {String} selector Filter\n * @param {Object} [context] If provided, matching elements must be a descendant of this element\n * @return {Object} New wrapped collection (containing zero or one element)\n * @chainable\n * @example\n * $('.selector').closest('.container');\n */\n\nexport const closest = (() => {\n\n const closest = function(selector, context) {\n const nodes = [];\n each(this, node => {\n while(node && node !== context) {\n if(matches(node, selector)) {\n nodes.push(node);\n break;\n }\n node = node.parentElement;\n }\n });\n return $(uniq(nodes));\n };\n\n return typeof Element === 'undefined' || !Element.prototype.closest ? closest : function(selector, context) {\n if(!context) {\n const nodes = [];\n each(this, node => {\n const n = node.closest(selector);\n if(n) {\n nodes.push(n);\n }\n });\n return $(uniq(nodes));\n } else {\n return closest.call(this, selector, context);\n }\n };\n})();\n","/**\n * @module Events\n */\n\nimport { each } from '../util';\nimport { closest } from '../selector/closest';\n\n/**\n * Shorthand for `addEventListener`. Supports event delegation if a filter (`selector`) is provided.\n *\n * @param {String} eventNames List of space-separated event types to be added to the element(s)\n * @param {String} [selector] Selector to filter descendants that delegate the event to this element.\n * @param {Function} handler Event handler\n * @param {Boolean} useCapture=false\n * @param {Boolean} once=false\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').on('click', callback);\n * $('.container').on('click focus', '.item', handler);\n */\n\nexport const on = function(eventNames, selector, handler, useCapture, once) {\n\n if(typeof selector === 'function') {\n handler = selector;\n selector = null;\n }\n\n let parts,\n namespace,\n eventListener;\n\n eventNames.split(' ').forEach(eventName => {\n\n parts = eventName.split('.');\n eventName = parts[0] || null;\n namespace = parts[1] || null;\n\n eventListener = proxyHandler(handler);\n\n each(this, element => {\n\n if(selector) {\n eventListener = delegateHandler.bind(element, selector, eventListener);\n }\n\n if(once) {\n const listener = eventListener;\n eventListener = event => {\n off.call(element, eventNames, selector, handler, useCapture);\n listener.call(element, event);\n };\n }\n\n element.addEventListener(eventName, eventListener, useCapture || false);\n\n getHandlers(element).push({\n eventName,\n handler,\n eventListener,\n selector,\n namespace\n });\n });\n\n }, this);\n\n return this;\n};\n\n/**\n * Shorthand for `removeEventListener`.\n *\n * @param {String} eventNames List of space-separated event types to be removed from the element(s)\n * @param {String} [selector] Selector to filter descendants that undelegate the event to this element.\n * @param {Function} handler Event handler\n * @param {Boolean} useCapture=false\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').off('click', callback);\n * $('#my-element').off('myEvent myOtherEvent');\n * $('.item').off();\n */\n\nexport const off = function(eventNames = '', selector, handler, useCapture) {\n\n if(typeof selector === 'function') {\n handler = selector;\n selector = null;\n }\n\n let parts,\n namespace,\n handlers;\n\n eventNames.split(' ').forEach(eventName => {\n\n parts = eventName.split('.');\n eventName = parts[0] || null;\n namespace = parts[1] || null;\n\n return each(this, element => {\n\n handlers = getHandlers(element);\n\n each(handlers.filter(item => {\n return (\n (!eventName || item.eventName === eventName) &&\n (!namespace || item.namespace === namespace) &&\n (!handler || item.handler === handler) &&\n (!selector || item.selector === selector)\n );\n }), item => {\n element.removeEventListener(item.eventName, item.eventListener, useCapture || false);\n handlers.splice(handlers.indexOf(item), 1);\n });\n\n if(!eventName && !namespace && !selector && !handler) {\n clearHandlers(element);\n } else if(handlers.length === 0) {\n clearHandlers(element);\n }\n\n });\n\n }, this);\n\n return this;\n};\n\n/**\n * Add event listener and execute the handler at most once per element.\n *\n * @param eventNames\n * @param selector\n * @param handler\n * @param useCapture\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').one('click', callback);\n */\n\nexport const one = function(eventNames, selector, handler, useCapture) {\n return on.call(this, eventNames, selector, handler, useCapture, 1);\n};\n\n/**\n * Get event handlers from an element\n *\n * @private\n * @param {Node} element\n * @return {Array}\n */\n\nconst eventKeyProp = '__domtastic_event__';\nlet id = 1;\nlet handlers = {};\nlet unusedKeys = [];\n\nexport const getHandlers = element => {\n if(!element[eventKeyProp]) {\n element[eventKeyProp] = unusedKeys.length === 0 ? ++id : unusedKeys.pop();\n }\n const key = element[eventKeyProp];\n return handlers[key] || (handlers[key] = []);\n};\n\n/**\n * Clear event handlers for an element\n *\n * @private\n * @param {Node} element\n */\n\nexport const clearHandlers = element => {\n const key = element[eventKeyProp];\n if(handlers[key]) {\n handlers[key] = null;\n element[eventKeyProp] = null;\n unusedKeys.push(key);\n }\n};\n\n/**\n * Function to create a handler that augments the event object with some extra methods,\n * and executes the callback with the event and the event data (i.e. `event.detail`).\n *\n * @private\n * @param handler Callback to execute as `handler(event, data)`\n * @return {Function}\n */\n\nexport const proxyHandler = handler => function(event) {\n return handler.call(this, augmentEvent(event));\n};\n\nconst eventMethods = {\n preventDefault: 'isDefaultPrevented',\n stopImmediatePropagation: 'isImmediatePropagationStopped',\n stopPropagation: 'isPropagationStopped'\n};\nconst returnTrue = () => true;\nconst returnFalse = () => false;\n\n/**\n * Attempt to augment events and implement something closer to DOM Level 3 Events.\n *\n * @private\n * @param {Object} event\n * @return {Function}\n */\n\nconst augmentEvent = event => {\n if(!event.isDefaultPrevented || event.stopImmediatePropagation || event.stopPropagation) {\n for(const methodName in eventMethods) {\n (function(methodName, testMethodName, originalMethod) {\n event[methodName] = function() {\n this[testMethodName] = returnTrue;\n return originalMethod && originalMethod.apply(this, arguments);\n };\n event[testMethodName] = returnFalse;\n }(methodName, eventMethods[methodName], event[methodName]));\n }\n if(event._preventDefault) {\n event.preventDefault();\n }\n }\n return event;\n};\n\n/**\n * Function to test whether delegated events match the provided `selector` (filter),\n * if the event propagation was stopped, and then actually call the provided event handler.\n * Use `this` instead of `event.currentTarget` on the event object.\n *\n * @private\n * @param {String} selector Selector to filter descendants that undelegate the event to this element.\n * @param {Function} handler Event handler\n * @param {Event} event\n */\n\nexport const delegateHandler = function(selector, handler, event) {\n const eventTarget = event._target || event.target;\n const currentTarget = closest.call([eventTarget], selector, this)[0];\n if(currentTarget && currentTarget !== this) {\n if(currentTarget === eventTarget || !(event.isPropagationStopped && event.isPropagationStopped())) {\n handler.call(currentTarget, event);\n }\n }\n};\n\nexport const bind = on;\nexport const unbind = off;\n","/**\n * @module trigger\n */\n\nimport { win, each } from '../util';\nimport { contains } from '../dom/contains';\n\nconst reMouseEvent = /^(mouse(down|up|over|out|enter|leave|move)|contextmenu|(dbl)?click)$/;\nconst reKeyEvent = /^key(down|press|up)$/;\n\n/**\n * Trigger event at element(s)\n *\n * @param {String} type Type of the event\n * @param {Object} data Data to be sent with the event (`params.detail` will be set to this).\n * @param {Object} [params] Event parameters (optional)\n * @param {Boolean} params.bubbles=true Does the event bubble up through the DOM or not.\n * @param {Boolean} params.cancelable=true Is the event cancelable or not.\n * @param {Mixed} params.detail=undefined Additional information about the event.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $('.item').trigger('anyEventType');\n */\n\nexport const trigger = function(type, data, {bubbles = true, cancelable = true, preventDefault = false} = {}) {\n\n const EventConstructor = getEventConstructor(type);\n const event = new EventConstructor(type, {\n bubbles,\n cancelable,\n preventDefault,\n detail: data\n });\n\n event._preventDefault = preventDefault;\n\n return each(this, element => {\n if(!bubbles || isEventBubblingInDetachedTree || isAttachedToDocument(element)) {\n dispatchEvent(element, event);\n } else {\n triggerForPath(element, type, {\n bubbles,\n cancelable,\n preventDefault,\n detail: data\n });\n }\n });\n};\n\nconst getEventConstructor = type => isSupportsOtherEventConstructors ? (reMouseEvent.test(type) ? MouseEvent : (reKeyEvent.test(type) ? KeyboardEvent : CustomEvent)) : CustomEvent;\n\n/**\n * Trigger event at first element in the collection. Similar to `trigger()`, except:\n *\n * - Event does not bubble\n * - Default event behavior is prevented\n * - Only triggers handler for first matching element\n *\n * @param {String} type Type of the event\n * @param {Object} data Data to be sent with the event\n * @example\n * $('form').triggerHandler('submit');\n */\n\nexport const triggerHandler = function(type, data) {\n if(this[0]) {\n trigger.call(this[0], type, data, {\n bubbles: false,\n preventDefault: true\n });\n }\n};\n\n/**\n * Check whether the element is attached to or detached from) the document\n *\n * @private\n * @param {Node} element Element to test\n * @return {Boolean}\n */\n\nconst isAttachedToDocument = element => {\n if(element === window || element === document) {\n return true;\n }\n return contains(element.ownerDocument.documentElement, element);\n};\n\n/**\n * Dispatch the event at the element and its ancestors.\n * Required to support delegated events in browsers that don't bubble events in detached DOM trees.\n *\n * @private\n * @param {Node} element First element to dispatch the event at\n * @param {String} type Type of the event\n * @param {Object} [params] Event parameters (optional)\n * @param {Boolean} params.bubbles=true Does the event bubble up through the DOM or not.\n * Will be set to false (but shouldn't matter since events don't bubble anyway).\n * @param {Boolean} params.cancelable=true Is the event cancelable or not.\n * @param {Mixed} params.detail=undefined Additional information about the event.\n */\n\nconst triggerForPath = (element, type, params = {}) => {\n params.bubbles = false;\n const event = new CustomEvent(type, params);\n event._target = element;\n do {\n dispatchEvent(element, event);\n } while(element = element.parentNode); // eslint-disable-line no-cond-assign\n};\n\n/**\n * Dispatch event to element, but call direct event methods instead if available\n * (e.g. \"blur()\", \"submit()\") and if the event is non-cancelable.\n *\n * @private\n * @param {Node} element Element to dispatch the event at\n * @param {Object} event Event to dispatch\n */\n\nconst directEventMethods = ['blur', 'focus', 'select', 'submit'];\n\nconst dispatchEvent = (element, event) => {\n if(directEventMethods.indexOf(event.type) !== -1 && typeof element[event.type] === 'function' && !event._preventDefault && !event.cancelable) {\n element[event.type]();\n } else {\n element.dispatchEvent(event);\n }\n};\n\n/**\n * Polyfill for CustomEvent, borrowed from [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill).\n * Needed to support IE (9, 10, 11) & PhantomJS\n */\n\n(() => {\n const CustomEvent = function(event, params = {\n bubbles: false,\n cancelable: false,\n detail: undefined\n }) {\n let customEvent = document.createEvent('CustomEvent');\n customEvent.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);\n return customEvent;\n };\n\n CustomEvent.prototype = win.CustomEvent && win.CustomEvent.prototype;\n win.CustomEvent = CustomEvent;\n\n})();\n\n/*\n * Are events bubbling in detached DOM trees?\n * @private\n */\n\nconst isEventBubblingInDetachedTree = (() =>{\n let isBubbling = false;\n const doc = win.document;\n if(doc) {\n const parent = doc.createElement('div');\n const child = parent.cloneNode();\n parent.appendChild(child);\n parent.addEventListener('e', function() {\n isBubbling = true;\n });\n child.dispatchEvent(new CustomEvent('e', {bubbles: true}));\n }\n return isBubbling;\n})();\n\nconst isSupportsOtherEventConstructors = (() => {\n try {\n new MouseEvent('click');\n } catch(e) {\n return false;\n }\n return true;\n})();\n","/**\n * @module Ready\n */\n\n/**\n * Execute callback when `DOMContentLoaded` fires for `document`, or immediately if called afterwards.\n *\n * @param handler Callback to execute when initial DOM content is loaded.\n * @return {Object} The wrapped collection\n * @chainable\n * @example\n * $(document).ready(callback);\n */\n\nexport const ready = function(handler) {\n if(/complete|loaded|interactive/.test(document.readyState) && document.body) {\n handler();\n } else {\n document.addEventListener('DOMContentLoaded', handler, false);\n }\n return this;\n};\n","/**\n * @module noConflict\n */\n\nimport { win } from './util';\n\n/*\n * Save the previous value of the global `$` variable, so that it can be restored later on.\n * @private\n */\n\nconst previousLib = win.$;\n\n/**\n * In case another library sets the global `$` variable before DOMtastic does,\n * this method can be used to return the global `$` to that other library.\n *\n * @return {Object} Reference to DOMtastic.\n * @example\n * var domtastic = $.noConflict();\n */\n\nexport const noConflict = function() {\n win.$ = previousLib;\n return this;\n};\n","/**\n * @module Selector (extra)\n */\n\nimport { each, toArray } from '../util';\nimport { $, matches } from './index';\n\n/**\n * Return children of each element in the collection, optionally filtered by a selector.\n *\n * @param {String} [selector] Filter\n * @return {Object} New wrapped collection\n * @chainable\n * @example\n * $('.selector').children();\n * $('.selector').children('.filter');\n */\n\nexport const children = function(selector) {\n const nodes = [];\n each(this, element => {\n if(element.children) {\n each(element.children, child => {\n if(!selector || (selector && matches(child, selector))) {\n nodes.push(child);\n }\n });\n }\n });\n return $(nodes);\n};\n\n/**\n * Add the elements of a wrapped collection to another.\n *\n * @param {String|Node|NodeList|Array} selector Query selector, `Node`, `NodeList`, array of elements, or HTML fragment string.\n * @return {Object} The extended wrapped collection\n * @example\n * $('.items').concat($('.more-items));\n * $('.items').concat('.more-items);\n * $('.items').concat('${item.partido.sigla} • ${item.nomeColigacao}
\nsanta catarina
${item.partido.sigla} • ${item.nomeColigacao}
33 |