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

Warn if rendering invalid element, fixes #3726 #8396

Conversation

ConnorAtherton
Copy link

This PR adds a warning whenever a user attempts to render an element unrecognized by the browser.

TODO

  • Ensure the test suite passes (npm test).
  • Add specific tests for validateDOMTag much like validateDOMNesting

The tests for ReactDOMComponent include a lot of custom web components that will now show a warning because they haven't been defined before they were used. I'm not sure how to solve this issue yet. I'm hesitant to change the existing specs and, from an initial glance, it looks like jsdom doesn't fully support the web component customElements property yet. @spicyj Any ideas on how to go around resolving this?

Here is a quick look at the warning:
screen shot 2016-11-23 at 08 30 05

Copy link
Contributor

@edvinerikson edvinerikson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is getting loaded on the server you can't use document.createElement. Not sure that is the case though

*
* https://www.w3.org/TR/custom-elements/#custom-elements-api
*/
knownTag = !(document.createElement(instance._tag) instanceof UnknownConstructor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does SSR still work with this enabled?

@@ -253,6 +254,8 @@ if (__DEV__) {
}

validateDOMNesting(null, String(content), this, this._ancestorInfo);
validateDOMTag(this, this._ancestorInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the changes in this file should be replicated in the Fiber component as well.

@ConnorAtherton ConnorAtherton changed the title 3726 warn if rendering invalid element Warn if rendering invalid element, fixes #3726 Nov 24, 2016
@sophiebits
Copy link
Collaborator

It would make sense to me to not warn on any tag that has a - in it.

@ConnorAtherton
Copy link
Author

Fixed in #9163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants