2

I have an HTML page with many <object> tags, each including a different SVG image.

Example:

<object type="image/svg+xml" data="first.svg"></object>
<object type="image/svg+xml" data="totally-different.svg"></object>   

In Google Chrome, the page initially displays as expected. However, if I browse away from the page, then return using the back/forward buttons, the SVG images are shuffled: they can appear inside the wrong <object> tag.

Example:
On first view, the page appears as per the markup:

<object type="image/svg+xml" data="first.svg">
  <!-- first.svg will appear here -->
</object>
<object type="image/svg+xml" data="totally-different.svg">
  <!-- totally-different.svg will appear here -->
</object>    

After back/forward, the images may be swapped

<object type="image/svg+xml" data="first.svg">
  <!-- totally-different.svg will appear here! -->
</object>
<object type="image/svg+xml" data="totally-different.svg">
  <!-- first.svg will appear here! -->
</object> 

How do I prevent this erroneous behaviour?

1 Answer 1

2

This is a known bug, #352762, in Blink, Chromium's rendering engine. At this time a patch has been submitted, but the bug is not yet fixed in the release version.

A workaround for the current release version is to add a name attribute to each of the <object> tags:

<object type="image/svg+xml" data="first.svg" name="first">
</object>

<object type="image/svg+xml" data="totally-different.svg"
  name="totally-different">
</object>

In this case, Chrome will correctly identify the SVG file in its cache, and not simply assign a random cached SVG file every time it comes across an <object> tag.

6
  • 1
    This bug affects Chrome 34, and is fixed in version 35 (currently in beta release). Commented Apr 28, 2014 at 10:40
  • @ErikDahlström do you know when v35 is scheduled for release? Chromium dev calendar suggests it's scheduled for about one month ago
    – Jeremy
    Commented Apr 28, 2014 at 23:11
  • 1
    Still a bug in v.48 (March, 2016). @Jeremy - very big THANK YOU for the solution, it works, but just out of curiosity - how did you find it out? It's not very intuitive/obvious... Commented Mar 10, 2016 at 7:42
  • Never mind, I can see it in comments on the bug report page :) Commented Mar 10, 2016 at 9:15
  • 1
    @konrad_firm thanks for filing the new bug report with chromium, if that was you. Maybe they can just re-use the same patch to fix it.
    – Jeremy
    Commented Mar 11, 2016 at 5:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.