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

Custom elements children prop gets coerced to string #5088

Closed
helly0d opened this issue Oct 8, 2015 · 2 comments
Closed

Custom elements children prop gets coerced to string #5088

helly0d opened this issue Oct 8, 2015 · 2 comments

Comments

@helly0d
Copy link

helly0d commented Oct 8, 2015

Hello,

In React 0.13.3 HTML5 custom tags were rendered fine. For example:

//... render function
  return (
    <my-custom-tag className="active custom-class" >
      <div>Hello World</div>
    </my-custom-tag>
  );

would render:

<my-custom-tag class="active custom-class" data-reactid=".1">
  <div>Hello World</div>
</my-custom-tag>

Since I am in the process of migrating to v0.14.0 i saw that the above renders like this:

<my-custom-tag classname="active custom-class" children="[object Object]" data-reactid=".1">
  <div>Hello World</div>
</my-custom-tag>

I can set in the JSX the property to be class instead of className and it will render with class attribute in the custom tag, but I am afraid this is not the intended behavior. If this is the intended behavior please close the issue and give me some documentation, because I tried to find something related to this for the last 5 hours.

@andreypopp
Copy link
Contributor

Dup of #4933

@jimfb
Copy link
Contributor

jimfb commented Oct 8, 2015

You can use class instead of className for custom tags. This is intended behavior. This behavior was chosen because we needed to support arbitrary attributes on custom tags. That's what #4933 is discussing, and we're probably going to keep that behavior unless someone comes up with a better idea. We'll keep that discussion in that other thread.

However, the children attribute is being set to "[object Object]" - that seems like wrong behavior to me. We can use this issue to track that regression.

@jimfb jimfb changed the title React 0.14.0 misbehaves at rendering HTML5 custom tags Custom elements children attribute renders incorrectly Oct 8, 2015
@jimfb jimfb changed the title Custom elements children attribute renders incorrectly Custom elements children prop gets coerced to string Oct 8, 2015
jimfb added a commit that referenced this issue Oct 30, 2015
Should not coerce children prop on custom elements to a string.  Fixes #5088
zpao pushed a commit to zpao/react that referenced this issue Nov 2, 2015
…coercion

Should not coerce children prop on custom elements to a string.  Fixes facebook#5088
(cherry picked from commit a2d26c8)
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