igor-alexandrov / wiselinks

If Turbolinks are not enough for you. Wiselinks makes your application work faster.
MIT License
724 stars 89 forks source link

Response headers X-Wiselinks-Title, X-Wiselinks-Description, etc is not processed #81

Open Novik opened 10 years ago

Novik commented 10 years ago

when Wiselnks use as target a standard container (body). Reason of this is a simple: _response.js.coffee

  _extract_title: ->
    if @_is_full_document_response()
      $('title', @_get_doc()).text()
    else
      @xhr.getResponseHeader('X-Wiselinks-Title')

  _is_full_document_response: ->
    @_get_doc_target_node().length is 1

  _get_doc_target_node: ->
    @$doc_target_node ?= $(@$target.selector, @_get_doc())

  _get_doc: ->
    @_doc ?= Response._get_document_parser().parse(@html)

_get_doc always return document with a body element. As result, we have _is_full_document_response => true. Is this a really correct behavior?

igor-alexandrov commented 10 years ago

No, of course it is not correct.

Novik commented 10 years ago

Workaround: add class attribute to the body tag and use corresponding selector as a target.

Спасибо за Вашу работу.

elbarto132 commented 9 years ago

With this fix i'm at least able to set the title using the header. But shouldn't the header be optional? If i don't set the header in the current version it gets set to an empty string. If i use Novik's patch it gets set to 'null'. I would expect that if i don't set the header the title should just stay.