Preact: 'markerWidth' and 'markerHeight' svg attributes getting converted to 'marker-width' and 'marker-height'

Created on 11 Mar 2020  路  8Comments  路  Source: preactjs/preact

The SVG attributes markerWidth and markerHeight getting converted to marker-width and marker-height which are invalid attributes.

Input:

<marker id="arrow" viewBox="-10 -10 20 20" markerWidth="20" markerHeight="20" />

Preact output:

<marker id="arrow" viewBox="-10 -10 20 20" marker-width="20" marker-height="20" />
beginner-friendly bug

Most helpful comment

oh no.. I was using v10.3.2.

All 8 comments

To add to the above: The expect output is that the attribute names are not changed in casing. See the pages on MDN:

...and here is a page with all SVG attributes https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute 馃帀鉁岋笍

馃憢 Curious about looking into this and I'm unable to reproduce on version 10.3.4.

In my sandbox, I'm still getting markerWidth and markerHeight as rendered attributes.

Also not aware of particular normalization conditions with SVG when creating elements https://github.com/preactjs/preact/blob/master/src/create-element.js#L11.

I might be missing something but would be glad to help!

Hey @ddayguerrero

These normalizations happen in our compat-layer and will only be there if you use preact/compat https://github.com/preactjs/preact/blob/master/compat/src/render.js#L137

Oh, missed that. Thanks for the guidance! 馃檱

Are you using the latest version of Preact? This was fixed in v10.3.3 with https://github.com/preactjs/preact/pull/2366
If you have a look at the tests it covers this test case for markerWidth and markerHeight 馃檪

@jamesb3ll good catch :+1:

@moklick are you sure that you are using the latest version of Preact?

oh no.. I was using v10.3.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marcosguti picture marcosguti  路  3Comments

philipwalton picture philipwalton  路  3Comments

nopantsmonkey picture nopantsmonkey  路  3Comments

skaraman picture skaraman  路  3Comments

k15a picture k15a  路  3Comments