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

add_attributes doesn't handle integers #4

Open
WidgetsBurritos opened this issue Jun 23, 2021 · 1 comment
Open

add_attributes doesn't handle integers #4

WidgetsBurritos opened this issue Jun 23, 2021 · 1 comment
Assignees

Comments

@WidgetsBurritos
Copy link

WidgetsBurritos commented Jun 23, 2021

There is a slight issue with the add_attributes() function on storybook side:

https://github.com/emulsify-ds/emulsify-twig-extensions/blob/master/packages/add-attributes-twig-extension/lib/add-attributes-twig-extension.js#L16-L24

        else {
          // Handle bem() output (pass in exactly the result).
          if (value.includes('=')) {
            attributes.push(value);
          }
          else {
            attributes.push(key + '="' + value + '"');
          }
        }

value.includes('=') assumes that value is a string. If it's an integer, it generates this error:

TypeError: value.includes is not a function

value should either be converted to a string prior to the check, or we should have a separate check to see if value is an integer.

I'm able to fake it for now by just doing something like this in my twig, where I change my value to a string:

{% set td_attributes = td_attributes|merge({'colspan': td.colspan ~ ''}) %}

But that's not a really clean solution. I think it makes more sense to fix it here.

Opening the issue for now, but I can try to open a PR later, if time permits (I'm about to head off on PTO for 2 weeks, so I'm unsure if I'll get to it before then or not).

┆Issue is synchronized with this Clickup task by Unito

@callinmullaney
Copy link
Contributor

PR created - #6

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

3 participants