You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time I author SVGs using JavaScript—without a library—I end up having to look up the SVG namespace URI (and others) to make sure that the elements I create behave properly. It seems like an enormous oversight that I can’t access the “http://www.w3.org/2000/svg” URI (or other equivalent XML namespace URIs) from, say, a static property on the SVGElement constructor or something. Instead I have look it up, or (if I’m feeling clever) find some way to trick the parser into handing me a properly constructed SVG element, all so the browser can see the magic 26 letters that will cause my paths to display.
Here’s an example of what I could do if the browser has a set of predefined constants available to use:
// if NS_SVG was a global constant defining the SVG namespace URIvarimage=document.createElementNS(NS_SVG,'image');
Here’s what that might look like if the namespace was defined on the element representation instead:
Please, please, create a common way that I can access these and other namespace constants directly in my scripts. I don’t have to look up the exact integers that represent WebGL constants and we successfully simplified the HTML doctype… I have confidence that we can make this happen.
This discussion was converted from issue #74 on October 23, 2020 22:13.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Every time I author SVGs using JavaScript—without a library—I end up having to look up the SVG namespace URI (and others) to make sure that the elements I create behave properly. It seems like an enormous oversight that I can’t access the “http://www.w3.org/2000/svg” URI (or other equivalent XML namespace URIs) from, say, a static property on the SVGElement constructor or something. Instead I have look it up, or (if I’m feeling clever) find some way to trick the parser into handing me a properly constructed SVG element, all so the browser can see the magic 26 letters that will cause my paths to display.
Here’s an example of what I could do if the browser has a set of predefined constants available to use:
Here’s what that might look like if the namespace was defined on the element representation instead:
Please, please, create a common way that I can access these and other namespace constants directly in my scripts. I don’t have to look up the exact integers that represent WebGL constants and we successfully simplified the HTML doctype… I have confidence that we can make this happen.
https://webwewant.fyi/wants/5f7dc6381eb8b910287121e6/
Beta Was this translation helpful? Give feedback.
All reactions