From c2ad005fea0c8a1170c77ec6353162f249c54378 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Tue, 2 May 2023 14:30:27 -0400 Subject: [PATCH 1/6] Update vdom.nim --- karax/vdom.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/karax/vdom.nim b/karax/vdom.nim index 1bec42d..2dcac56 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -67,6 +67,16 @@ type const selfClosing = {area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr} + +const + svgElements = {animate..view} + mathElements = {maction..semantics} + +var + svgNamespace* = "http://www.w3.org/2000/svg" + mathNamespace* = "http://www.w3.org/1998/Math/MathML" + #global var settings: defaults are already set up, but may be adjusted in one shot for the user's entire project + type EventKind* {.pure.} = enum ## The events supported by the virtual DOM. From 3626af40cc75603504b0eab5815338443e3684f9 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Tue, 2 May 2023 14:39:38 -0400 Subject: [PATCH 2/6] Update karax.nim --- karax/karax.nim | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/karax/karax.nim b/karax/karax.nim index 7fdcde0..899f1d4 100644 --- a/karax/karax.nim +++ b/karax/karax.nim @@ -194,8 +194,15 @@ proc toDom*(n: VNode; useAttachedNode: bool; kxi: KaraxInstance = nil): Node = result = toDom(x.expanded, useAttachedNode, kxi) attach n return result - else: - result = document.createElement(toTag[n.kind]) + else: # we are dealing with fundamental tags at this point, and not nim components/functions + if svgElements.contains(n.kind): + result = document.createElementNS(svgNamespace,toTag[n.kind]) #svg elements need to be declared with a namespace + #we apply a default so that users can just treat it like html in the DSL while learning + + elif mathElements.contains(n.kind): #mathML needs a similar treatment as svg + result = document.createElementNS(mathNamespace,toTag[n.kind]) + else: + result = document.createElement(toTag[n.kind]) attach n for k in n: appendChild(result, toDom(k, useAttachedNode, kxi)) From b0da219eafcaf48ba4c8713fb2200009c8e0c744 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Thu, 11 May 2023 12:35:17 -0400 Subject: [PATCH 3/6] Update vdom.nim --- karax/vdom.nim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/karax/vdom.nim b/karax/vdom.nim index 2dcac56..0513959 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -69,8 +69,9 @@ const link, meta, param, source, track, wbr} const - svgElements = {animate..view} + svgElements = {animate..view} mathElements = {maction..semantics} + needingNamespace = {svg,math} var svgNamespace* = "http://www.w3.org/2000/svg" From bf1a0d9263aa184edf227d81521b12b2b2c0a889 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Thu, 11 May 2023 13:16:58 -0400 Subject: [PATCH 4/6] Update karax.nim --- karax/karax.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/karax/karax.nim b/karax/karax.nim index 899f1d4..1172ec5 100644 --- a/karax/karax.nim +++ b/karax/karax.nim @@ -195,11 +195,11 @@ proc toDom*(n: VNode; useAttachedNode: bool; kxi: KaraxInstance = nil): Node = attach n return result else: # we are dealing with fundamental tags at this point, and not nim components/functions - if svgElements.contains(n.kind): - result = document.createElementNS(svgNamespace,toTag[n.kind]) #svg elements need to be declared with a namespace + if (svgElements*needingNamespace).contains(n.kind): + result = document.createElementNS(svgNamespace,toTag[n.kind]) #svg top-level elements need to be declared with a namespace #we apply a default so that users can just treat it like html in the DSL while learning - elif mathElements.contains(n.kind): #mathML needs a similar treatment as svg + elif (mathElements*needingNamespace}.contains(n.kind): #mathML needs a similar treatment as svg result = document.createElementNS(mathNamespace,toTag[n.kind]) else: result = document.createElement(toTag[n.kind]) From 336508230bdb44df99a5c30e5e8f8c14942d5f85 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Thu, 11 May 2023 13:33:32 -0400 Subject: [PATCH 5/6] Update karax.nim --- karax/karax.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/karax/karax.nim b/karax/karax.nim index 1172ec5..2383b5b 100644 --- a/karax/karax.nim +++ b/karax/karax.nim @@ -199,7 +199,7 @@ proc toDom*(n: VNode; useAttachedNode: bool; kxi: KaraxInstance = nil): Node = result = document.createElementNS(svgNamespace,toTag[n.kind]) #svg top-level elements need to be declared with a namespace #we apply a default so that users can just treat it like html in the DSL while learning - elif (mathElements*needingNamespace}.contains(n.kind): #mathML needs a similar treatment as svg + elif (mathElements*needingNamespace).contains(n.kind): #mathML needs a similar treatment as svg result = document.createElementNS(mathNamespace,toTag[n.kind]) else: result = document.createElement(toTag[n.kind]) From 761dc3c1b4b8e2c6ce51ef2d6a8d3df6aebe7f62 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Thu, 11 May 2023 13:37:12 -0400 Subject: [PATCH 6/6] Update vdom.nim --- karax/vdom.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/karax/vdom.nim b/karax/vdom.nim index 0513959..e1d2f58 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -69,9 +69,9 @@ const link, meta, param, source, track, wbr} const - svgElements = {animate..view} - mathElements = {maction..semantics} - needingNamespace = {svg,math} + svgElements* = {animate..view} + mathElements* = {maction..semantics} + needingNamespace* = {svg,math} var svgNamespace* = "http://www.w3.org/2000/svg"