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

<svg:use/> allows for infinite reference cycles. #770

Open
george-steel opened this issue Jan 2, 2020 · 4 comments
Open

<svg:use/> allows for infinite reference cycles. #770

george-steel opened this issue Jan 2, 2020 · 4 comments

Comments

@george-steel
Copy link

Under #UseElement, the text

If the referenced element is a (shadow-including) ancestor of the ‘use’ element, then this is an invalid circular reference and the ‘use’ element is in error.

requires the generation of infinitely deep shadow trees if it references something containing a reference cycle. It should be corrected to

If the referenced element is a (shadow-including) ancestor of the ‘use’ element or the referenced element of such an ancestor, then this is an invalid circular reference and the ‘use’ element is in error.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jan 3, 2020

I'm not sure I understand the distinction between those two statements, if we take “shadow-including” to include the shadow trees generated by use references.

Can you give a short example code snippet that shows the problem?

@george-steel
Copy link
Author

<svg>
  <defs>
    <g id="a">
      <rect x="10" y="10" width="50" height="50" fill="red"/>
      <use href="#b" x="60"/>
    </g>
    <g id="b">
      <rect x="10" y="10" width="50" height="50" fill="green"/>
      <use href="#c" x="60"/>
    </g>
    <g id="c">
      <rect x="10" y="10" width="50" height="50" fill="blue"/>
      <use href="#a" x="60"/>
    </g>
  </defs>
  <use href="#a"/>
</svg>

(also on codepen)

In the shadow copy of #c, #a is not an ancestor but a copy of it is.

@AmeliaBR
Copy link
Contributor

AmeliaBR commented Jan 4, 2020

Oh, I see. I would word this as:

If the referenced element, or a cloned instance of the referenced element, is a (shadow-including) ancestor of the ‘use’ element, then this is an invalid circular reference and the ‘use’ element is in error.

Do you think that would address your concerns?

@george-steel
Copy link
Author

Yes it does. Thanks for the improvement.

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

2 participants