jquery-pjax icon indicating copy to clipboard operation
jquery-pjax copied to clipboard

SVG <title> elements replace the page title

Open tdhooper opened this issue 9 years ago • 2 comments

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()

tdhooper avatar Mar 10 '16 12:03 tdhooper

@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 avatar Dec 04 '17 08:12 staabm

Upstream PR erstellt

staabm avatar Jan 21 '18 20:01 staabm