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 · 3 comments · May be fixed by #2054
Open

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

murkle opened this issue Nov 30, 2023 · 3 comments · May be fixed by #2054
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.

Chaostheorie added a commit to Chaostheorie/coderdojo-website-mirror that referenced this issue Jul 20, 2024
Just open+save in inkscape to work around
svg/svgo#1863
@condemil
Copy link

condemil commented Jul 23, 2024

I also faced the same issue, the MRE that I come up with:

<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 72 24">
    <path d="M35 11 Q34.22 10.19 34.58 10.12 Q34.94 10.05 35.27 10.05 L35.27 10.05 Q35 10 36 10"/>
</svg>

traceback:

TypeError: Cannot read properties of undefined (reading '0')
    at reflectPoint ([email protected]/node_modules/svgo/plugins/convertPathData.js:1160:37)
    at [email protected]/node_modules/svgo/plugins/convertPathData.js:802:43
    at Array.filter (<anonymous>)
    at filters ([email protected]/node_modules/svgo/plugins/convertPathData.js:397:15)
    at Object.enter ([email protected]/node_modules/svgo/plugins/convertPathData.js:183:20)
    at visit ([email protected]/node_modules/svgo/lib/xast.js:52:30)
    at visit ([email protected]/node_modules/svgo/lib/xast.js:68:9)
    at visit ([email protected]/node_modules/svgo/lib/xast.js:61:7)
    at invokePlugins ([email protected]/node_modules/svgo/lib/svgo/plugins.js:25:7)
    at Object.fn ([email protected]/node_modules/svgo/lib/svgo/plugins.js:57:7)

@kristofzerbe
Copy link

I have the same issue, but only when I run over complete folder. It stops somewhere (every run differently) with the same error as @condemil and all processed SVG are empty. Processing each file individually works !?

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

Successfully merging a pull request may close this issue.

4 participants