-
Notifications
You must be signed in to change notification settings - Fork 92
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
[RFC] Namespace support in knete #185
Conversation
For it to work, setting the className was replaced with setAttribute("class", x). See also facebook/react#1590 |
Problems with it:
|
I don't understand this PR. Knete is code duplication and should be refactored. It's also not documented, is it? Do you want to use Knete? |
I'm trying it yes. My previous attempt #179 to add svg support to karax failed, I tried to work on knete instead, being just a thin dsl on top of the dom. So my example produces: let ns_369098792 = getChildNamespace(Namespace.none, Tag.svg)
let tmp_369098791 = newNode(ns_369098792, Tag.svg)
setAttr(tmp_369098791, "width", "100")
setAttr(tmp_369098791, "height", "100")
let ns_369098799 = getChildNamespace(ns_369098792, Tag.circle)
let tmp_369098798 = newNode(ns_369098799, Tag.circle)
setAttr(tmp_369098798, "cx", "50")
setAttr(tmp_369098798, "cy", "50")
setAttr(tmp_369098798, "r", "40")
setAttr(tmp_369098798, "stroke", "blue")
setAttr(tmp_369098798, "stroke-width", "4")
setAttr(tmp_369098798, "fill", "currentColor")
setAttr(tmp_369098798, "class", "icon")
add(tmp_369098791, tmp_369098798) which is equivalent to: let svg = document.createElementNS("http://www.w3.org/2000/svg", "svg")
svg.setAttribute("width", "100")
svg.setAttribute("height", "100")
let c = document.createElementNS("http://www.w3.org/2000/svg", "circle")
c.setAttribute("cx", "50")
c.setAttribute("cy", "50")
c.setAttribute("r", "40")
c.setAttribute("stroke", "green")
c.setAttribute("stroke-width", "4")
c.setAttribute("fill", "yellow")
svg.appendChild(c) ...but the logic for determining the correct namespace is moved at runtime (see the getChildNamespace proc). That makes svg as well as mathml elements render properly. |
I think it would be better to add a buildSvg overload for karax, but I'm waiting for your feedback and suggestions. Main problems with that are: nodeName doesn't return all uppercase when inside the svg/mathml namespace, which breaks |
Closing this as we added SVG support in #271 |
example: