-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Support for custom DOM elements & attributes #2746
Comments
Before As for attributes, there is some work but the plan is to let anything through eventually. We need to make the transfer and consumption of And lastly for namespaced attributes, there's a bit that needs to be done. The first is just adding support so we know when to use We did talk a long time ago about exposing a way to register elements but as we get rid of the whitelist it doesn't make sense moving forward. Registering attributes may be a thing though. We need to figure out the details of all of this to support web components so it's definitely all in progress. |
@zpao thanks for the comment. I think you could maybe provide some value boxing function to indicate that given prop is indeed an attribute: React.DOM({ flex: React.AttributeNS(XUL_NS, 2),
align: React.Attribute("center") }, children) In the end I managed to find a workaround by generating custom element constructors wrapped in react component (see https://github.com/Gozala/firefox.html/blob/react/js/element.js#L18-L87) That enables me to define custom elements by providing it's field anotations: Although I'm afraid this way I'll am throwing some optimizations away. |
Is there a reason that |
AFAIK, only namespaced attributes need support. The above approach makes sense. What do you think @zpao? |
I'm confused. Isn't this supposed to be working since 0.12? The release notes state "lower case tag names are always treated as HTML tags, upper case tag names are always treated as composite components". Yet when I try to render |
Great. Thanks @andrewrota |
@andrewrota Can we use custom elements/web components in React 0.12.2? I tried and I'm getting the above error. I created a StackOverflow thread: http://stackoverflow.com/questions/28751629/react-0-12-2-error-lower-case-component-names-paper-button-are-no-longer-su |
@gnestor, no, you'd need 0.13.0-alpha.1 or greater I believe. |
@andrewrota Ok thanks. |
I just upgraded to React 0.14.2 and noticed that I can add arbitrary attributes to custom elements now (this didn't work with 0.13). I'm guessing this can be closed now? |
When you use web components with React, you can pass any attributes. |
Is there reason why React restricts you to just a subset of DOM elements and attributes ? Unfortunately it makes it really hard to use it with new HTML or non standard features unless support for that is added.
I noticed I could create custom elements via
React.createFactory("custom")
https://github.com/facebook/react/blob/master/src/browser/ReactDOM.js#L30
https://github.com/facebook/react/blob/master/src/classic/element/ReactElement.js#L201-L209
But it's not documented & not sure if supported in long term. And even if it was supported that still does not solve problem of attributes as ones not listed in the docs seem to be ignored.
I think it would be good idea to allow defining custom virtual DOM Elements with a custom list of attributes so that users could implement them even if support for new element isn't in the core yet.
Finally support for namespaces would be super useful for using react even in more environments & should not be too hard either. I have successfully used vtree / vdom to do that.
The text was updated successfully, but these errors were encountered: