Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlink:href in <animate>, <use>, etc. doesn't work in sourceless iframes #700

Open
longsonr opened this issue Jun 7, 2019 · 4 comments
Open

Comments

@longsonr
Copy link

longsonr commented Jun 7, 2019

As described in https://www.w3.org/TR/SVG2/linking.html#processingURL-absolute

See https://bugzilla.mozilla.org/show_bug.cgi?id=1553430 for what we think that implies.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jul 6, 2019

If anything in that section (Processing of URL references) is defined in a way that breaks something that worked in SVG 1, it's my mistake. But, SVG 1 left a lot of stuff undefined, and this is definitely something that wasn't considered: using same-document URL references within documents that don't have a resolvable URL for the document as a whole.

The CSS special rules for #target URLs were designed to help with CSS specified in different document. But, they have the side effect of automatically handling this situation, too.

For SVG (xlink:)href references, we don't want to go quite as general as the CSS rules, as that would mess things up when you reference elements in a different file and then want the internal references in that second file to still be resolved locally. But we can definitely still tweak the rules for URL processing that I added to SVG 2.

The current rules require you to make a URL absolute first, then decide if it is same-document second. This approach was intended to ensure that any URL references to the current document are recognized as same-document URLs, whether or not they start with a # mark. But, we need a way to make that work even if you're in a document with an unresolvable URL.

Interestingly, the HTML rules for resolving URLs in iframe srcdoc are very similar to the rules for resolving URLs in shadow trees: they use the base URL of the containing document. We should therefore try to handle both issues at the same time & in the same way. See WICG/webcomponents#179 and cc @tabatkins

@AmeliaBR AmeliaBR changed the title xlink:href in <animate> doesn't work in sourceless iframes xlink:href in <animate>, <use>, etc. doesn't work in sourceless iframes Jul 6, 2019
@css-meeting-bot
Copy link
Member

The SVG Working Group just discussed xlink:href in <animate>, <use>, etc. doesn't work in sourceless iframes.

The full IRC log of that discussion <myles> Topic: xlink:href in <animate>, <use>, etc. doesn't work in sourceless iframes
<myles> GitHub: https://github.com//issues/700
<myles> krit: Do we need to discuss any non-<use> elements?
<myles> AmeliaBR: It's not specific to <animate>, it's just about xlink:href in general
<myles> krit: Is there a difference between <use> and <animate>? Or will this apply everywhere
<myles> AmeliaBR: It will apply everywehre
<myles> AmeliaBR: The issue is about URL resolution. An iframe srcdoc doesn't have its own URL. It's defined in HTML to behave as the parent frame's URL applies to the srcdoc. But if you put inline svg which needs hrefs to its own document, then that's the wrong base URL.
<myles> AmeliaBR: so #target inside the srcdoc doesn't work becuase it looks for one in the main page instead of the local page.
<myles> AmeliaBR: This is similar to SVG inside shadow dom. The rules there say, first, look in the main document. Initial implementations' SVG cross references weren't working inside the shadow dom. There is a general acceptance now that for shadow trees, hash-only URLs should look in the local trees first, but some of the details there are still undecided as well.
<myles> krit: For the shadow dom discussion, rniwa and annevk had different opinions, but eventually resolved on something. Would it be possible that we ask rniwa and annevk to comment on this issue as well?
<myles> AmeliaBR: Yes.
<myles> AmeliaBR: Getting feedback from HTML would be useful because this whole thing comes from an HTML situation. It's important to try to coordinate with the shadow dom behaviors. I'm not sure how much of that has actually gotten reflected into specs.
<myles> krit: There are similarities with shadow dom. Hopefully we can get a solution soon.
<myles> krit: AmeliaBR, is there something else you are looking for?
<myles> AmeliaBR: I can't remember.
<myles> AmeliaBR: one option is to go like CSS and just say if the URL starts with a hash, treat it specially. But if we can have more general rules, that would be helpful anyway.
<myles> AmeliaBR: At this point, if you can follow-up with anybody relevant, that would be great.

@rniwa
Copy link

rniwa commented Jul 17, 2019

Resolving xlink:href in sourceless iframes as we do in shadow trees make sense to me.

@css-meeting-bot
Copy link
Member

The SVG Working Group just discussed xlink:href in sourceless iframes, and agreed to the following:

  • RESOLVED: Defer to HTML for how to handle local references inside sourceless iframes
The full IRC log of that discussion <heycam> Topic: xlink:href in sourceless iframes
<heycam> github: https://github.com//issues/700
<heycam> AmeliaBR: we have discussed this
<heycam> ... this is related to Shadow DOM in the simple sense that it's a similar problem in Shaodw DOM
<heycam> ... same document references in trees that don't have a base URL
<heycam> ... but the iframe is a little more isolated from the parent document
<heycam> ... if cross reference works inside a shadow tree, it should also work inside an iframe document
<heycam> ... that's even more isolated
<heycam> rniwa: I think anchor tag inside sourceless iframe works as well
<heycam> ... this should somehow be resolved in the HTML spec
<heycam> ... so we should be using that mechanism
<heycam> AmeliaBR: is that in the HTML spec?
<heycam> rniwa: hyperlinks already work...
<heycam> AmeliaBR: the special rules for SVG hash references
<heycam> heycam: that's defined in CSS somewhere?
<heycam> AmeliaBR: that's another set of special rulse
<heycam> s/rulse/rules/
<heycam> AmeliaBR: I think we can resolve to file an issue on HTML, and ask them to clarify how these sourceless iframes work with the specific use case of breaking SVGs
<heycam> RESOLVED: Defer to HTML for how to handle local references inside sourceless iframes
<heycam> ACTION: AmeliaBR to file an HTM Lissue for sourceless iframe local references
<trackbot> Created ACTION-3871 - File an htm lissue for sourceless iframe local references [on Amelia Bellamy-Royds - due 2019-09-26].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants