   constructor: (@currentSnapshot, @newSnapshot, @isPreview) ->
     @currentHeadDetails = @currentSnapshot.headDetails
     @newHeadDetails = @newSnapshot.headDetails
+    @currentBody = @currentSnapshot.bodyElement
     @newBody = @newSnapshot.bodyElement
 
   render: (callback) ->

  getNewHeadProvisionalElements: ->
    @newHeadDetails.getProvisionalElements()

  getNewBodyPermanentElements: ->
    @newBody.querySelectorAll("[id][data-turbolinks-permanent]")

  findCurrentBodyPermanentElement: (element) ->
    document.body.querySelector("##{element.id}[data-turbolinks-permanent]")

  getNewBodyScriptElements: ->
    @newBody.querySelectorAll("script")

  findFirstAutofocusableElement: ->
    document.body.querySelector("[autofocus]")

  importPermanentElement = (permanentElement, replaceableElement) ->
    permanentElement.parentNode.replaceChild(permanentElement.cloneNode(true), permanentElement)
    replaceableElement.parentNode.replaceChild(permanentElement, replaceableElement)
    permanentElement

    @copyNewHeadProvisionalElements()

  replaceBody: ->
    permanentElements = @extractCurrentBodyPermanentElements()
    @activateNewBodyScriptElements()
    @assignNewBody()
    @replaceNewBodyPermanentElements(permanentElements)
    @replacePlaceholdersForPermanentElements(permanentElements)

  shouldRender: ->
    @newSnapshot.isVisitable() and @trackedElementsAreIdentical()
