defunkt / jquery-pjax

pushState + ajax = pjax
https://pjax.herokuapp.com
MIT License
16.73k stars 1.97k forks source link

SVG <title> elements replace the page title #616

Open tdhooper opened 8 years ago

tdhooper commented 8 years ago

If the page contains inline SVG with a <title>, it will get used instead of the main <title> for the page title.

For example, a page returned with the following, will be be titled 'SVG Title'

<title>Page title</title>

<svg width="500" height="300" xmlns="http://www.w3.org/2000/svg">
  <g>
    <title>SVG Title</title>
    <rect x="10" y="10" width="200" height="50"
    style="fill:none; stroke:blue; stroke-width:1px"/>
  </g>
</svg>

This happens because the last title in the page is used:

// If there's a <title> tag in the header, use it as
// the page's title.
obj.title = findAll($head, 'title').last().text()
staabm commented 6 years ago

@mislav as we also run into this problem I would provide a patch for this problem.

would it be enought to use the first() title instead of the last one? or maybe only take <title> attributes into accounts of top level elements?

staabm commented 6 years ago

Upstream PR erstellt