-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Templates don't work with SVG #2598
Comments
so, not exactly a solution, but might get someone one step closer to implementing a fix: https://jsfiddle.net/wzsy8p5j/1/ specifically, if you have an element and you use if you instead use i suspect this is a very old quirk present from when SVGs were namespace-aware (i checked multiple browsers), and suggests "magic" is performed when an SVG fragment is loaded (where the xmlns is implied for all elements within the fragment, historically SVGs were encapsulated within <script> blocks or loaded as separate documents, each having an xmlns assigned to them.) however, when i tried to use knockout to set the xmlns attribute on the templated circle elements and this did not work, apparently they can't be specified on the element itself when most likely as a "fix" for this we would need a new binding that allows the specification of an xmlns for element creation via for example, a new binding cleverly named 'xmlns' might be obvious enough, giving us something like this:
or, given your fiddle, you could do this:
but that's going to require someone to update the source code, add tests, and get a PR merged @SteveSanderson @mbest i'd be more than happy to work with someone on this. if someone wants to collab, hit me up on discord wilson0x4d#4327 i can do the heavy lifting. |
@wilson0x4d your suspicion is correct, this is a relic of the early browser era. These commits in knockout/tko that give TKO support of SVGs in JSX may give some illumination, and in any case I think you're on the right path:
|
See: https://jsfiddle.net/gburca/hwb92esf/33/
The generated HTML looks identical, yet the 1st SVG drawing is not displaying the circles (even though they're in the generated HTML). The 2nd drawing (which doesn't use templates) displays them properly.
The text was updated successfully, but these errors were encountered: