 #
 Tether = require 'tether'
 React = require 'react'
+ReactDOM = require 'react-dom'
 _ = require './prelude'
 $ = React.createElement
 

    document.addEventListener 'mousedown', @handleEvent
    document.addEventListener 'focus', @handleEvent, true

    React.render @renderAttachment(), @root, =>
      @tether = new Tether
        classPrefix: 'm'
        element: @root

      @tether.position()

  componentDidUpdate: =>
    ReactDOM.render @renderAttachment(), @root, => @tether?.position()

  componentWillUnmount: =>
    ReactDOM.unmountComponentAtNode @root

    @tether.destroy?()
    document.body.removeChild @root
