   get: (doc = document) ->
     node:   tag = doc.querySelector 'meta[name="csrf-token"]'
     token:  tag?.getAttribute? 'content'
-    
+
   update: (latest) ->
     current = @get()
     if current.token? and latest? and current.token isnt latest
       current.node.setAttribute 'content', latest
-      
+
 browserCompatibleDocumentParser = ->
   createDocumentUsingParser = (html) ->
     (new DOMParser).parseFromString html, 'text/html'

    link.href = url
  link.href.replace link.hash, ''


triggerEvent = (name) ->
  event = document.createEvent 'Events'
  event.initEvent name, true, true
  document.dispatchEvent event


invalidContent = (xhr) ->
  !xhr.getResponseHeader('Content-Type').match /^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/



  xhr.onload = =>
    triggerEvent 'page:receive'

    if xhr.status.toString().match(/^4/)
      locationReplace(url)
    else if invalidContent(xhr) or assetsChanged (doc = createDocument xhr.responseText)
        document.location.reload()
    else
      changePage extractTitleAndBody(doc)...
      reflectRedirectedUrl xhr
