preact-compat icon indicating copy to clipboard operation
preact-compat copied to clipboard

textLength should not be kebap-cased

Open chrisv2 opened this issue 6 years ago • 4 comments

textLenght is a valid attribute on svg:tspan and svg:text: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/textLength

Unfortunately, textLength gets kebap-cased to text-length because it matches the CAMEL_PROPS regex.

Comparing with the SVG attribute reference, the following attributes are likely affected:

  • clipPathUnits
  • glyphRef
  • markerHeight, markerUnit, markerWidth
  • textLength
  • xChannelSelector

chrisv2 avatar Jul 04 '18 11:07 chrisv2

Can confirm, clipPathUnits gets rendered as clip-pathunits.

itslevo avatar Jul 27 '18 10:07 itslevo

Hmm - it looks like the regex that is handling clipPathUnits is missing /g, so it only replaces the first uppercase character:

https://github.com/developit/preact-compat/blob/6029c6e25f6d1c6461d5cc24a9c8bdc781f6ab87/src/index.js#L123

developit avatar Aug 06 '18 14:08 developit

Is there a temporary workaround until this is fixed?

ikoruk avatar Jan 16 '19 12:01 ikoruk

@ikoruk this bit me today. With the g flag it gets converted to kebab which isn't the solution as far as I can tell with. Is there a way to denylist certain attributes, or svg attributes as a whole? I'm not super familiar with the internals.

itsthesteve avatar Feb 13 '19 03:02 itsthesteve