knockout / knockout

Knockout makes it easier to create rich, responsive UIs with JavaScript
http://knockoutjs.com/
Other
10.43k stars 1.52k forks source link

Templates don't work with SVG #2598

Open gburca opened 1 year ago

gburca commented 1 year ago

See: http://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.

wilson0x4d commented 1 year ago

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 createElement('circle') and append the result to the svg, it does not render. surprise! this is consistent in every browser i tested, and is not knockout-specific behavior but occurs with plain-old-javascript as well.

if you instead use createElementNS('http://www.w3.org/2000/svg', 'circle') and append the result to the svg, the circle renders just fine. surprise again!

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 Githubissues.

  • Githubissues is a development platform for aggregating issues.