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

Reac isCompatTag validator accepts leading dash '-' #7163

Closed
claudiopro opened this issue Jan 6, 2018 · 2 comments · Fixed by #7164
Closed

Reac isCompatTag validator accepts leading dash '-' #7163

claudiopro opened this issue Jan 6, 2018 · 2 comments · Fixed by #7164
Labels
Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@claudiopro
Copy link
Contributor

claudiopro commented Jan 6, 2018

Choose one: is this a bug report or feature request? Bug report

The React isCompatTag accepts a leading dash '-' in tag names. This means it will accept JSX tag names like <-div>.

Input Code

Adding a test suite for the React isCompatTag validator:

  suite("isCompatTag", function() {
    it("rejects leading dash '-'", function() {
      assert(t.react.isCompatTag("-div") === false);
      assert(t.react.isCompatTag("-span") === false);
      assert(t.react.isCompatTag("-a") === false);
      assert(t.react.isCompatTag("-input") === false);
    });
  });

Produces this error:

  7752 passing (2m)
  94 pending
  1 failing

  1)  rejects leading dash '-':

      AssertionError [ERR_ASSERTION]: false == true
      + expected - actual

      -false
      +true

      at Context.<anonymous> (packages/babel-types/test/validators.js:58:7)

Babel/Babylon Configuration (.babelrc, package.json, cli command)

N/A, reproduced in unit tests

Expected Behavior

Tag names with leading dash characters '-' are not valid

Current Behavior

Tag names with leading dash characters '-' are accepted

Possible Solution

Fix this regexp:

https://github.com/babel/babel/blob/master/packages/babel-types/src/validators/react/isCompatTag.js#L3

Context

Spotted in @hzoo's tweet: https://twitter.com/left_pad/status/949301094903099393

Your Environment

software version(s)
Babel
Babylon
node
npm
Operating System
@babel-bot
Copy link
Collaborator

Hey @claudiopro! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@claudiopro
Copy link
Contributor Author

Preparing a fix

@yavorsky yavorsky added the Has PR label Jan 8, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 3, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants