Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read properties of undefined (reading '0') #1863

Open
murkle opened this issue Nov 30, 2023 · 1 comment
Open

TypeError: Cannot read properties of undefined (reading '0') #1863

murkle opened this issue Nov 30, 2023 · 1 comment
Labels

Comments

@murkle
Copy link

murkle commented Nov 30, 2023

Attached file issue41.svg gives this error:

TypeError: Cannot read properties of undefined (reading '0')
    at Object.getPropertyDescriptor [as property] (C:\Users\<username>\AppData\Roaming\npm\node_modules\svgo\node_modules\csso\node_modules\css-tree\cjs\utils\names.cjs:69:24)

with this command
svgo issue41.svg
and also when opened here https://jakearchibald.github.io/svgomg/

image

issue41

(File is from the canvg test suite https://github.com/canvg/canvg/blob/master/test/svgs/issue41.svg )

@murkle murkle added the bug label Nov 30, 2023
@SethFalco
Copy link
Member

SethFalco commented Nov 30, 2023

The issue is ultimately that the file is a valid SVG, but has invalid styles, from what I understand.

Here is an MRE of the issue:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 225, 425">
  <path style="fill- opacity:0.5" d="M0 50 l50 50 0 20z"/>
</svg>

The parser encounters a CSS property, but the file jumps straight to declaring another CSS property rather than assigning a value to it.

(This appears to be done pseudo-accidentally in the test suite by putting a line break in the middle of the property name.)

I'm not sure if this should be resolved in CSSTree, CSSO, or SVGO. 🤔
Probably in CSSO or SVGO as it's ultimately invalid styles afaik, but I'll look into this further later. Just jotting notes down for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants