 
   scrollToElement: (container) ->
     if window.location.hash
-      top = $(container + " " + window.location.hash).offset().top
-      $('body').scrollTo(top)
+      $el = $("#{container} #{window.location.hash}")
+      $('body').scrollTo($el.offset().top) if $el.length
 
   # Activate a tab based on the current action
   activateTab: (action) ->

        document.getElementById('commits').innerHTML = data.html
        $('.js-timeago').timeago()
        @commitsLoaded = true
        @scrollToElement(".commits")

  loadDiff: (source) ->
    return if @diffsLoaded

      success: (data) =>
        document.getElementById('diffs').innerHTML = data.html
        @diffsLoaded = true
        @scrollToElement("#diffs")

  # Show or hide the loading spinner
  #
