/** * DOM utilities */ export default { /** * Returns text + text of children of given node * @param {NodeElement} node * @return {String} */ getText(node){ let s = node.textContent || node.innerText || node.innerHTML.replace(/<[^<>]+>/g, ''); s = s.replace(/^\s+/, '').replace(/\s+$/, ''); return s; }, /** * Creates an html element with given collection of attributes * @param {String} tag a string of the html tag to create * @param {Array} an undetermined number of arrays containing the with 2 * items, the attribute name and its value ['id','myId'] * @return {Object} created element */ create(tag){ if(!tag || tag===''){ return; } let el = document.createElement(tag), args = arguments; if(args.length > 1){ for(let i=0; i