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

How to pass props without value to component? #23

Closed
ghashi opened this issue Jun 22, 2018 · 1 comment
Closed

How to pass props without value to component? #23

ghashi opened this issue Jun 22, 2018 · 1 comment

Comments

@ghashi
Copy link

ghashi commented Jun 22, 2018

the problem

amp-accordion has an animate prop that I would like too add, but I don't find how to do it.

what I've tried

  1. set it as specified in the docs
<Amp.AmpAccordion animate>

renders

<amp-accordion animate="true" class="i-amphtml-element i-amphtml-layout-container i-amphtml-layout">

which is not a valid amp-html

  1. Set animate={null}
<Amp.AmpAccordion animate={null}>

renders

<amp-accordion class="i-amphtml-element i-amphtml-layout-container i-amphtml-layout">
@dfrankland
Copy link
Owner

Hello!

This is more related to the W3C DOM specification and React in general. Any attribute with an empty string will render into the DOM without a value.


W3C relevant documentation: https://www.w3.org/TR/html5/syntax.html#elements-attributes

Empty attribute syntax
Just the attribute name. The value is implicitly the empty string.

In the following example, the disabled attribute is given with the empty attribute syntax:

<input disabled>

If an attribute using the empty attribute syntax is to be followed by another attribute, then there must be a space character separating the two.


Example JSX:

<Amp.AmpAccordion animate="">

...renders to...

<amp-accordion animate class="i-amphtml-element i-amphtml-layout-container i-amphtml-layout">

@ghashi ghashi closed this as completed Jun 22, 2018
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