FIX: URL links in SVG should have target='_blank'#31578
FIX: URL links in SVG should have target='_blank'#31578timhoffm wants to merge 1 commit intomatplotlib:mainfrom
Conversation
b45c9b8 to
49b03ff
Compare
|
This is a bit of a change in behaviour - I tried the SVG url demo example, and before this PR the link opens in the same window, and after it opens in a new window. Using It should definitely get a release note though, and optionally this might be a good oppurtunity to de-duplicate at least |
When embedding SVG in HTML, link `href`s can target different browsing contexts. This e.g. leads to links inside SVGs in matplotlib#31497 replacing the SVG image instead of opening a new browser window. The solution is to set `target="_blank"` for all links that implement `Artist.get_url()`. This is always intended as an external link, so universally adding `target="_blank"` is justified. Background info: https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/target https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/target#_blank
49b03ff to
cf25ca5
Compare
|
I've add a behavior change message. I'm not convinced de-duplicating the link code is worth it. Writing a function for it doesn't make it significantly shorter, and the indirection IMHO rather reduces readability. The only advantage would be easier and more consistent changes, but since I don't expect this code to be touched a lot, that doesn't weigh strongly. |
|
Could / should this still go into 3.11 if we make another RC? |
When embedding SVG in HTML, link
hrefs can target different browsing contexts. This e.g. leads to links inside SVGs in #31497 replacing the SVG image instead of opening a new browser window.The solution is to set
target="_blank"for all links that implementArtist.get_url(). This is always intended as an external link, so universally addingtarget="_blank"is justified.Background info:
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/target
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/target#_blank