 
   getMedia: (mediaId) ->
     root = @getDOMNode()
-    root.querySelector("##{mediaId}")
+    try
+      root.querySelector("##{mediaId}")
+    catch error
+      # silently handle error in case selector is
+      # still invalid.
+      console.warn(error)
+      false
 
   cleanUpLinks: ->
     root = @getDOMNode()

  linkPreview: (link) ->
    mediaId = link.hash.replace('#', '')
    mediaDOM = @getMedia(mediaId) if mediaId
    mediaCNXId = @getCnxIdOfHref(link.getAttribute('href')) or @props.cnxId or @getCnxId?()
    previewNode = document.createElement('span')
    previewNode.classList.add('media-preview-wrapper')

      </MediaPreview>

    React.render(mediaPreview, previewNode)
    return null

  processLink: (link) ->
    if @isMediaLink(link)
      @linkPreview(link)
    else
      return link

