 
   extractTitleAndBody = (doc) ->
     title = doc.querySelector 'title'
-    [ title?.textContent, removeNoscriptTags(doc.body), CSRFToken.get(doc).token, 'runScripts' ]
+    [ title?.textContent, removeNoscriptTags(doc.querySelector('body')), CSRFToken.get(doc).token, 'runScripts' ]
 
   installHistoryChangeHandler = (event) ->
     if event.state?.turbolinks

    keepNodes(body, allNodesToKeep)
    return

  executeScriptTags = ->
    scripts = Array::slice.call document.body.querySelectorAll 'script:not([data-turbolinks-eval="false"])'
    for script in scripts when script.type in ['', 'text/javascript']

    #  - DOMParser isn't defined
    #  - createDocumentUsingParser returns null due to unsupported type 'text/html' (Chrome, Safari)
    #  - createDocumentUsingDOM doesn't create a valid HTML document (safeguarding against potential edge cases)
    # Use createDocumentUsingFragment if the previously selected parser does not
    # correctly parse <form> tags. (Safari 7.1+ - see github.com/rails/turbolinks/issues/408)
    buildTestsUsing = (createMethod) ->
      buildTest = (fallback, passes) ->
        passes: passes()
        fallback: fallback

      structureTest = buildTest createDocumentUsingWrite, =>
        (createMethod '<html><body><p>test')?.body?.childNodes.length is 1

      formNestingTest = buildTest createDocumentUsingFragment, =>
        (createMethod '<html><body><form></form><div></div></body></html>')?.body?.childNodes.length is 2

      [structureTest, formNestingTest]

    try
      if window.DOMParser
        docTests = buildTestsUsing createDocumentUsingParser
        createDocumentUsingParser
    catch e
      docTests = buildTestsUsing createDocumentUsingDOM
      createDocumentUsingDOM
    finally
      for docTest in docTests
        return docTest.fallback unless docTest.passes

  if browserSupportsTurbolinks
    @visit = fetch
