-
Notifications
You must be signed in to change notification settings - Fork 353
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
Allow arbitrarily nested <use> elements #117
Conversation
Hey @jonathantneal, is there anything I can do to move this along? I've also offered to help in #101 if you want to make me a contributor. |
Anyone want to review this one for me? @jonathantneal? |
I'd like to use element-closest instead of the inline |
id: id | ||
}); | ||
|
||
// prepare the xhr ready state change event | ||
loadreadystatechange(xhr); | ||
} else { | ||
// embed the local id into the svg | ||
embed(svg, document.getElementById(id)); | ||
embed(parent, document.getElementById(id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: would it be better to pass in both the svg
and parent
so that we don't have to search through the DOM again? Its likely that svg and use are close together, but its would be more efficient this way. You would have to change the obj being passed into xhr._embeds
as well.
@@ -199,3 +202,14 @@ function svg4everybody(rawopts) { | |||
oninterval(); | |||
} | |||
} | |||
|
|||
function getSVGAncestor(node) { | |||
var svg = node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor: I think leaving it as node is clearer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dist will need to be rebuilt before merge :)
Thanks for the review, @timeiscoffee! I gave you access to the branch just in case you have time to get to this before I do. |
@shawnbot which branch did you give me the access to? I don't see it unfortunately :( |
@timeiscoffee you should have write access to this fork's |
@shawnbot I tried to push to that
|
Derf, maybe that feature only works for user forks and not org forks. Sorry! I'm happy to close this PR if you have fixes ready. |
Sure, I would be happy to :) |
Closing as per above discussion, since #132 has been merged |
This PR addresses the use case (heh) for
<use>
elements that aren't direct descendants of their SVG element, e.g.The changes allow for this by removing checks for direct "ancestry" (
/svg/i.test(svg.nodeName)
) and perform replacements on the<use>
element's parent, which also makes it easier to style those elements with CSS descendent selectors.We've added a test to
test/index.html
that works, and the code passes linting muster. We've ensured that thevalidate()
andfallback()
callbacks still get the SVG element as their second argument, so those should still work as expected—though some tests for those would be very welcome.