title: OnClickListener in Electron
body: <p>What am I doing wrong?
  If I select the same element from Console and add a click listener… it works… however, this code doesn't work</p>
  
  <pre><code>const Template = require('./Template')
  const mustache = require('mustache')
  const DOMHelper = require('./DOMHelper')
  
  class SymbolDefiner extends Template {
    constructor (key, data) {
      super(key)
      this._data = data
    }
  
    render () {
      super.render(arguments)
      const parent = this._parent
      const props = this._props
      const eventListener = this._listener
  
      const addSymbol = DOMHelper.createElement('button.btn.btn-primary', parent)
      const btnText = document.createTextNode('Add Symbol')
      addSymbol.appendChild(btnText)
  
      console.log(addSymbol) // this log succeeds
      addSymbol.addEventListener('click', function () {
          console.log('xx')
      })
    }
  }
  
  module.exports = SymbolDefiner
  </code></pre>
  
  <p>The DOMHelper is just an easy function to add elements into the DOM by using very simple 'div#id.class-1.class-2' string.
  Here is the code for DOMHelper:</p>
  
  <pre><code>const obj = {}
  
  obj.createElement = function (selector, parent, props) {
      const details = selector.split('#')
      let eleName, eleId, classList
      if (details.length &gt; 1) {
          // id is present
          eleName = details[0]
          const attribs = details[1].split('.')
          eleId = attribs.shift()
          classList = attribs
      } else {
          const attribs = details[0].split('.')
          eleName = attribs.shift()
          classList = attribs
      }
  
      const element = document.createElement(eleName)
      element.setAttribute('id', eleId || '')
      for (var i in classList) {
          element.classList.add(classList[i])
      }
  
      if (props) {
          for (var key in props) {
              element.setAttribute(key, props[key])
          }
      }
  
      if (parent) {
          parent.appendChild(element)
      }
  
      return element
  }
  
  module.exports = obj
  </code></pre>