From 1f5a21c6120e242915dcaa2926281d8907bada83 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Sat, 22 Apr 2023 18:26:16 -0400 Subject: [PATCH 1/3] Update vdom.nim track elements that need a namespace when added to the DOM. Provide a global default for Math and SVG elements --- karax/vdom.nim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/karax/vdom.nim b/karax/vdom.nim index 3821d92..6dc12a5 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -68,6 +68,27 @@ const selfClosing = {area, base, br, col, embed, hr, img, input, link, meta, param, source, track, wbr} +const + svgElements = {animate, animateMotion, animateTransform, circle, clipPath, defs, desc, + `discard`, ellipse, feBlend, feColorMatrix, feComponentTransfer, + feComposite, feConvolveMatrix, feDiffuseLighting, feDisplacementMap, + feDistantLight, feDropShadow, feFlood, feFuncA, feFuncB, feFuncG, feFuncR, + feGaussianBlur, feImage, feMerge, feMergeNode, feMorphology, feOffset, + fePointLight, feSpecularLighting, feSpotLight, feTile, feTurbulence, + filter, foreignObject, g, image, line, linearGradient, marker, mask, + metadata, mpath, path, pattern, polygon, polyline, radialGradient, rect, + `set`, stop, svg, switch, symbol, stext, textPath, tspan, + unknown, use, view} + + mathElements = {maction, math, menclose, merror, mfenced, mfrac, mglyph, mi, mlabeledtr, + mmultiscripts, mn, mo, mover, mpadded, mphantom, mroot, mrow, ms, mspace, + msqrt, mstyle, msub, msubsup, msup, mtable, mtd, mtext, mtr, munder, + munderover, semantics} + +var + svgNamespace = "http://www.w3.org/2000/svg" + mathNamespace = "http://www.w3.org/1998/Math/MathML" + type EventKind* {.pure.} = enum ## The events supported by the virtual DOM. onclick, ## An element is clicked. From 24c64a929ec22592a8cdc6391632d41bd0775049 Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Sat, 22 Apr 2023 19:59:50 -0400 Subject: [PATCH 2/3] Update vdom.nim make namespace declarations user-modifiable --- karax/vdom.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/karax/vdom.nim b/karax/vdom.nim index 6dc12a5..faeb50a 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -86,8 +86,9 @@ const munderover, semantics} var - svgNamespace = "http://www.w3.org/2000/svg" - mathNamespace = "http://www.w3.org/1998/Math/MathML" + 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 8aff1f8211dc173084c171e57dc6d1a6acb8048d Mon Sep 17 00:00:00 2001 From: scattergory <111326462+scattergory@users.noreply.github.com> Date: Sat, 22 Apr 2023 20:50:15 -0400 Subject: [PATCH 3/3] terser syntax enums are ordinal types, so this works shorter file size and about as readable --- karax/vdom.nim | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/karax/vdom.nim b/karax/vdom.nim index faeb50a..3a5ffdf 100644 --- a/karax/vdom.nim +++ b/karax/vdom.nim @@ -69,21 +69,9 @@ const link, meta, param, source, track, wbr} const - svgElements = {animate, animateMotion, animateTransform, circle, clipPath, defs, desc, - `discard`, ellipse, feBlend, feColorMatrix, feComponentTransfer, - feComposite, feConvolveMatrix, feDiffuseLighting, feDisplacementMap, - feDistantLight, feDropShadow, feFlood, feFuncA, feFuncB, feFuncG, feFuncR, - feGaussianBlur, feImage, feMerge, feMergeNode, feMorphology, feOffset, - fePointLight, feSpecularLighting, feSpotLight, feTile, feTurbulence, - filter, foreignObject, g, image, line, linearGradient, marker, mask, - metadata, mpath, path, pattern, polygon, polyline, radialGradient, rect, - `set`, stop, svg, switch, symbol, stext, textPath, tspan, - unknown, use, view} + svgElements = {animate..view} - mathElements = {maction, math, menclose, merror, mfenced, mfrac, mglyph, mi, mlabeledtr, - mmultiscripts, mn, mo, mover, mpadded, mphantom, mroot, mrow, ms, mspace, - msqrt, mstyle, msub, msubsup, msup, mtable, mtd, mtext, mtr, munder, - munderover, semantics} + mathElements = {maction..semantics} var svgNamespace* = "http://www.w3.org/2000/svg"