observablehq / htl

A tagged template literal that allows safe interpolation of values into HTML, following the HTML5 spec
https://observablehq.com/@observablehq/htl
ISC License
305 stars 24 forks source link

Case-correct SVG attributes? #7

Closed mbostock closed 3 years ago

mbostock commented 4 years ago

HTML5 defines automatic case correction for certain SVG attributes:

altglyph altGlyph
altglyphdef altGlyphDef
altglyphitem altGlyphItem
animatecolor animateColor
animatemotion animateMotion
animatetransform animateTransform
clippath clipPath
feblend feBlend
fecolormatrix feColorMatrix
fecomponenttransfer feComponentTransfer
fecomposite feComposite
feconvolvematrix feConvolveMatrix
fediffuselighting feDiffuseLighting
fedisplacementmap feDisplacementMap
fedistantlight feDistantLight
fedropshadow feDropShadow
feflood feFlood
fefunca feFuncA
fefuncb feFuncB
fefuncg feFuncG
fefuncr feFuncR
fegaussianblur feGaussianBlur
feimage feImage
femerge feMerge
femergenode feMergeNode
femorphology feMorphology
feoffset feOffset
fepointlight fePointLight
fespecularlighting feSpecularLighting
fespotlight feSpotLight
fetile feTile
feturbulence feTurbulence
foreignobject foreignObject
glyphref glyphRef
lineargradient linearGradient
radialgradient radialGradient
textpath textPath

However, in order to do this, we’d need to track whether we’re in the SVG namespace, because it should only apply to SVG elements.

clarkevans commented 3 years ago

This is a hard issue. Tracking namespace is ugly. In our Julia fork, we decided to convert snake_case to kebab-case but, due to SVG, leave camelCase alone. This is working well. HTML, SVG and MathML do not use snake_case. That said, doing this would be an incompatible break for an established project such as this. However, perhaps you could add snake_case now; and set a flag to disable camelCase.