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

Color Type does not support "inherit" and does not work without a value #2315

Closed
chadfurman opened this issue Jun 29, 2021 · 4 comments
Closed

Comments

@chadfurman
Copy link
Contributor

Describe the bug
Using the "colorType" validator with an optional attribute causes cannot read property 'match' of undefined errors. Likely due to https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/types/color.js#L24

I don't want the color to have a default value, because there is not support for the 'inherit' color property here: https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/types/helpers/colors.js and I don't want them to have any of these matching colors or any hex color etc.

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom mjml component that uses the color validator on an attribute without a default value
  2. Use this component in some MJML rendering code somewhere but don't give the color attribute a value
  3. Render it to HTML in the normal way
  4. Note the error

Expected behavior
There should be some way of allowing font color to be inherited while still allowing font colors to be specified and providing for validation.

MJML environment (please complete the following information):
Appears in latest source. Found while using mjml 4.7.0

@iRyusa
Copy link
Member

iRyusa commented Jun 29, 2021

Yup you're right !
At least the fix isn't that hard, a small guard in the getValue function should do the trick here. Same for inherit we can safely add it to the color list and it will fix #1955 too 😄

Can you open a PR about this ?

@chadfurman
Copy link
Contributor Author

PR open: #2317

Any chance we can get this back-ported as 4.7.2?

@iRyusa
Copy link
Member

iRyusa commented Jun 30, 2021

We don't update older version of MJML 4.X is the main release channel, thanks for this PR 👍

@iRyusa
Copy link
Member

iRyusa commented Jul 22, 2021

Now live in 4.10.2 thanks !

@iRyusa iRyusa closed this as completed Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants