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

handle null values for tags (and fix eslinting error) #165

Merged
merged 1 commit into from
Nov 6, 2016

Conversation

matthewheck
Copy link
Contributor

If the primaryAttributeKey's value is null, then we ignore that entire tag. This is mostly useful for programmatic definitions of tag values where the data store may not be fully defined. This resolves #162.

For instance (and exemplified in test code), if an icon is being described, but null is provided in the href, the tag will not be added.

I also fixed an eslint error on src/Helmet.js ln 24.

@doctyper
Copy link
Contributor

doctyper commented Aug 15, 2016

@matthewheck this would prevent Helmet from being able to handle value-less attributes. For example:

<Helmet
    script={[
        {"async": undefined}
    ]}
/>

It would also prevent you from removing an un-needed attribute on render. For example, if you wanted to remove the className or data attribute of a particular style element for identification purposes.

@cwelch5
Copy link
Contributor

cwelch5 commented Oct 30, 2016

@matthewheck Thanks for your patience on this issue. We appreciate the PR. But @doctyper is correct, we still want to allow for undefined/null values for attributes for specific cases like the one he quotes above.

Your original issue #162 refers to the toLowerCase function throwing and that seems to be the real error case we need to check for. We should still allow the tag to be rendered though. The real trick is how we will check for duplicates of async: undefined, which I don't think the current code supports.

If you'd like to update, let me know. And thanks again for your patience.

@cwelch5
Copy link
Contributor

cwelch5 commented Nov 5, 2016

@matthewheck ah, on second look, this is a valid solution. Thanks for the detailed consideration.

@doctyper This only affects primary keys (i.e. "name",
"charset", "http-equiv", "rel", "href", "property", "src", "innerHTML", "cssText") that have undefined/null values. async is not a primary key, and with this PR will still render as a valueless attribute. But note, with your particular example, it wouldn't render regardless of this PR because there is no primary key specified.

@cwelch5 cwelch5 merged commit f0b971c into nfl:master Nov 6, 2016
@matthewheck
Copy link
Contributor Author

@cwelch5 - Apologies for not following up on the initial comments from you and @doctyper, but I'm glad this could be used!

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

Successfully merging this pull request may close these issues.

Tags handling fail with null value
3 participants