     document.location.href = document.location.href
   else
     window.scrollTo 0, 0
-
 
 clone = (original) ->
   return original if not original? or typeof original isnt 'object'

        refreshedNodes.push(newNode)

  refreshedNodes

addPermanentNodesInBody = (body) ->
  for newNode in body.querySelectorAll('[data-turbolinks-permanent]')
    unless nodeId = newNode.getAttribute('id')
      throw new Error "Turbolinks partial replacement: change key elements must have an id."

    if existingNode = document.querySelector('[id="'+nodeId+'"]')
      newNode.parentNode.replaceChild(existingNode, newNode)
  return

executeScriptTags = ->
  scripts = Array::slice.call document.body.querySelectorAll 'script:not([data-turbolinks-eval="false"])'

  triggerEvent EVENTS.CHANGE
  triggerEvent EVENTS.UPDATE

refreshAllExceptWithKeys = (keys, body, sourceBody) ->
  allNodesToKeep = []

  for key in keys
    for node in sourceBody.querySelectorAll('[id^="'+key+'"]')
      allNodesToKeep.push(node)

  keepNodes(body, allNodesToKeep)
