text: /**
   * TODO: Ideally this would be a NodeList.prototype.forEach polyfill
   * This seems to fail in IE8, requires more investigation.
   * See: https://github.com/imagitama/nodelist-foreach-polyfill
   */
  export function nodeListForEach (nodes, callback) {
    if (window.NodeList.prototype.forEach) {
      return nodes.forEach(callback)
    }
    for (var i = 0; i < nodes.length; i++) {
      callback.call(window, nodes[i], i, nodes)
    }
  }
  
  // Used to generate a unique string, allows multiple instances of the component without
  // Them conflicting with each other.
  // https://stackoverflow.com/a/8809472
  export function generateUniqueID () {
    var d = new Date().getTime()
    if (typeof window.performance !== 'undefined' && typeof window.performance.now === 'function') {
      d += window.performance.now() // use high-precision timer if available
    }
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
      var r = (d + Math.random() * 16) % 16 | 0
      d = Math.floor(d / 16)
      return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
    })
  }
  
  export function on (elSelector, eventName, selector, fn) {
    var element = document.querySelector(elSelector)
  
    element.addEventListener(eventName, function (event) {
      var possibleTargets = element.querySelectorAll(selector)
      var target = event.target
  
      for (var i = 0, l = possibleTargets.length; i < l; i++) {
        var el = target
        var p = possibleTargets[i]
  
        while (el && el !== element) {
          if (el === p) {
            return fn.call(p, event)
          }
  
          el = el.parentNode
        }
      }
    })
  }
  